Sunday, June 21, 2009

Automating Repetitive Twitter Tasks Using Linux

First, I realize this is going to generate some issues for some, since Twitter's use is primarily for micro-blogging, keeping connected with others, but some have been using it for other various reasons.

Image representing Twitter as depicted in Crun...Image via CrunchBase

I think the producing backlinks (which really doesn't work as far as Google is concerned...but I digress) and driving website traffic are two good examples, and these are what I've been investigating with a couple of accounts at Twitter.

One of those accounts is @zippydpinhead. I picked on him because I used to read Zippy the Pinhead comic strips in HighTimes magazine in my early 20's and thought it was...*dude*...*funny*...*cough**cough*...

I primarily use Ubuntu for my workstation these days, but have used Linux for years on the desktop and in small enterprise.

My experiments were first to see if automation worked. Fortunately we have curl and a multitude of posts on the subject floating about the internet.

My zippy character posts several times per day, using this crontab entry the following simple shell script and the fortune program. It is supposed to redirect stderr to a log, and stdout to /dev/null. I'm still experimenting with the redirect bit, so please correct me if it's wrong ;) :

# This runs our script 6 times starting at 1pm
*/10 13 * * * /home/me/bin/zippy.sh
#!/bin/sh

# Compose our message using fortune, and the zippyism's
MSG=`fortune zippy`
curl -s -u zippydpinhead:zippypassword -d "status=$MSG http://is.gd/16zaD #zippythepinhead" http://twitter.com/statuses/update.xml 2>/where/youwant/logs/zippytwits.log 1>/dev/null

This found me wondering if I could automate other things...so I came up with this script, that pulls down my followers, parses the contents, and adds a few tweets on Fridays for #followfriday

#!/bin/bash

USER=`grep twitter.com ~/.netrc | awk '{printf $4}'`
PASS=`grep twitter.com ~/.netrc | awk '{printf $6}'`
TEMP="tempff.txt"
NAMES="followers.txt"
RAND=`cat /proc/sys/kernel/random/uuid | cut -c1-4 | od -d | head -1 | cut -d' ' -f2`

# This gets a max of 100 users from our followers list
# since we know we have > 2000 followers, we'll randomly select
# from one of 20 pages
PAGE=`expr $RAND % 20 + 1`

curl --netrc -s http://twitter.com/statuses/followers.xml?page=$PAGE > $TEMP

# This rips everthing out except the properly formatted screen name
sed -e "/<screen_name>/!d" \
    -e 's/^\ *//' \
    -e 's/<\/\{0,1\}screen_name>//g' \
    -e 's/^/@/' $TEMP > $NAMES
    
# remove our temp file
rm $TEMP

# Extract followers
NFOLL="10" # This is the number of followers we will cull from the list
LINES=`cat $NAMES | wc -l`
LINE=`expr $RAND % $LINES + 1`
MSG=`head -$LINE $NAMES | tail -$NFOLL`

# Announce our ff
curl --netrc -s -d "status=Follow Us!: $MSG #FF http://bit.ly/nFu0I" http://twitter.com/statuses/update.xml

# remove our ff file
rm $NAMES

If you change the amount that tail grabs from the followers1.txt line (it's -10 right now) you can modify the number of users you want to suggest for #ff

I recognize the reason why this bot-like method of updating your Twitter account will be unpopular with most, but how and why you use these methods are up to you.

Reblog this post [with Zemanta]

Thursday, June 18, 2009

Tweaking Indexing Service

The 'Where do you want to go today?' logoImage via Wikipedia

Looking for methods to exclude files in our Indexing Service repository, I found some information on the MSDN with sparse descriptions of registry values.

Fortunately, Microsoft KB article 322896 provides a direct set if instructions.

Reblog this post [with Zemanta]

The Search for a Great Tiff iFilter

I recently wrote a VBScript utility that queries the contents of an Indexing Service database, finds the indexed Fax documents (CCITT Group 4 (2d) Tiff's), sorts and moves them to another repository located on a SAN.

Option Explicit
Dim oCon
Dim oCmd
Dim oRst
Dim sQry
Dim sString
Dim sScope
Dim sAqScan
Dim sFile
Dim sPath
Dim sMoveTo
Dim sNum
Dim FSO
Dim sDate
Dim sDosText
Dim sDateDir
Dim sDateDiff
Dim sMonth
Dim sDay
Dim sYear
Dim nCnt


'///////////////////////////////////////////
'
' Create the FSO
'
'////////////////////////////////////////////////

Set FSO = CreateObject("Scripting.FileSystemObject")


'/////////////////////////////////////////////////
'
'   Scope, Aquaius scan dir and Query.
'
'////////////////////////////////////////////////

sScope = "F:\Incoming Fax\CWHHM\"
sAqScan = "F:\Scanned Docs\Aquarius\14CWHHM\"
sQry = "Select Path, Filename, Size, Contents " _
  & "FROM Scope('DEEP TRAVERSAL OF " & chr(34) & sScope & chr(34) & "') "


'/////////////////////////////////////////////////
'
'   Meridian Search and move.
'
'////////////////////////////////////////////////

sString = "Meridian"
sMoveTo = sScope & "Meridian\"
Call ConnectDb
Call MoveIn


'/////////////////////////////////////////////////
'
'   Boise Search and move.
'
'////////////////////////////////////////////////

sString = "Boise"
sMoveTo = sScope & "Boise\"
Call ConnectDb
'Call MoveIn


'//////////////////////
' We will assume the rest
' are Boise documents

Dim sFolder
Dim sFileColl

' ///////////////////////////////////////////
' Set the folder and file collection
Set sFolder = FSO.GetFolder(sScope)
Set sFileColl = sFolder.Files

' //////////////////////////////////////////
' Loop over the direcory of remaining files
' and move them into the moveto dir
For Each sFile in sFileColl
    ' This is needed to avoid trying
    ' to move Thumb.db files where
    ' some usually exist at the destination.
    ' the movefile method will fail in that case.
    On Error Resume Next
    FSO.MoveFile sFile, sMoveTo
    sNum = sNum + 1
Next

Set sFolder = Nothing
Set sFileColl = Nothing


' //////////////////////////////////////////////
'
' Now wait a number of minutes so we can
' query on the DOS
'
' //////////////////////////////////////////////

If sNum < 50 Then
        'WScript.Echo "Sleeping for 5  minutes"
        WScript.Sleep 300000
ElseIf sNum < 150 Then
        'WScript.Echo "Sleeping for 10  minutes"
        WScript.Sleep 600000
ElseIf sNum < 250 Then
        'WScript.Echo "Sleeping for 20  minutes"
        WScript.Sleep 1200000
End If

'------------------------------/////////////// END


'/////////////////////////////////////////////////
'
'   Meridian Date Search and move.
'
'////////////////////////////////////////////////

sScope = "F:\Incoming Fax\CWHHM\Meridian\"
sQry = "Select Path, Filename, Size, Contents " _
  & "FROM Scope('DEEP TRAVERSAL OF " & chr(34) & sScope & chr(34) & "') "
  
  
sDosText = "Date of Service: "
sDate = Pd(Month(Date()),2) & "/" & Pd(Day(Date()),2) & "/" & Year(Date())
sDateDir = Pd(Month(Date()),2) & Pd(Day(Date()),2) & Year(Date())

For nCnt = 1 to 25

' First set the move to location
sMoveTo = sAqScan & "MDN\" & sDateDir & "\"

' Now set the search string
sString = sDosText & sDate

' Now look for the DOS
Call ConnectDb

' And now move them
MoveOver(sMoveTo)

' Reduce the date by one day
sDate = DateAdd("d", -1, sDate)

'Re-pad the date
sDateDiff = Split(sDate, "/")
sMonth = sDateDiff(0)
sDay = sDateDiff(1)
sYear = sDateDiff(2)

sDate = Pd(sDateDiff(0),2) & "/" & Pd(sDateDiff(1),2) & "/" & sDateDiff(2)
sDateDir = Pd(sDateDiff(0),2) & Pd(sDateDiff(1),2) & sDateDiff(2)

Next


'If there are any left, move them into an UNKDOS folder
sMoveTo = sAqScan & "MDN\UNKDOS\"

If Not FSO.FolderExists(sMoveTo) Then
    FSO.CreateFolder(sMoveTo)
End If

' ///////////////////////////////////////////
' Set the folder and file collection
Set sFolder = FSO.GetFolder(sScope)
Set sFileColl = sFolder.Files

' //////////////////////////////////////////
' Loop over the direcory of remaining files
' and move them into the moveto dir
For Each sFile in sFileColl
    FSO.MoveFile sFile, sMoveTo
Next

'------------------------------/////////////// END


'/////////////////////////////////////////////////
'
'   Boise Date Search and move.
'
'////////////////////////////////////////////////

sScope = "F:\Incoming Fax\CWHHM\Boise\"
sQry = "Select Path, Filename, Size, Contents " _
  & "FROM Scope('DEEP TRAVERSAL OF " & chr(34) & sScope & chr(34) & "') "
  
sDosText = "Date of Service: "
sDate = Pd(Month(Date()),2) & "/" & Pd(Day(Date()),2) & "/" & Year(Date())
sDateDir = Pd(Month(Date()),2) & Pd(Day(Date()),2) & Year(Date())

For nCnt = 1 to 25

' First set the move to location
sMoveTo = sAqScan & "BSE\" & sDateDir & "\"

' Now set the search string
sString = sDosText & sDate

' Now look for the DOS
Call ConnectDb

' And now move them
MoveOver(sMoveTo)

' Reduce the date by one day
sDate = DateAdd("d", -1, sDate)

'Re-pad the date
sDateDiff = Split(sDate, "/")
sMonth = sDateDiff(0)
sDay = sDateDiff(1)
sYear = sDateDiff(2)

sDate = Pd(sDateDiff(0),2) & "/" & Pd(sDateDiff(1),2) & "/" & sDateDiff(2)
sDateDir = Pd(sDateDiff(0),2) & Pd(sDateDiff(1),2) & sDateDiff(2)

Next

'If there are any left, move them into an UNKDOS folder
sMoveTo = sAqScan & "BSE\UNKDOS\"

If Not FSO.FolderExists(sMoveTo) Then
    FSO.CreateFolder(sMoveTo)
End If

' ///////////////////////////////////////////
' Set the folder and file collection
Set sFolder = FSO.GetFolder(sScope)
Set sFileColl = sFolder.Files

' //////////////////////////////////////////
' Loop over the direcory of remaining files
' and move them into the moveto dir
For Each sFile in sFileColl
    FSO.MoveFile sFile, sMoveTo
Next

'------------------------------/////////////// END




'/////////////////////////////////////////////////
'
'   First Move Sub
'
'////////////////////////////////////////////////

Sub MoveIn()

' Loop over the query until it is empty
Do While Not oRst.EOF
    sFile = oRst("Path")
    FSO.MoveFile sFile, sMoveTo
    oRst.MoveNext
    sNum = sNum + 1
Loop


End Sub

'------------------------------/////////////// END


'/////////////////////////////////////////////////
'
'   Big Move Sub
'
'////////////////////////////////////////////////

Function MoveOver(sMoveTo)

Do While Not oRst.EOF
    sFile = oRst("Path")
          If FSO.FolderExists(sMoveTo) Then
              'MsgBox "Moving file " & sFile & " to " & sMoveTo & "."
              FSO.MoveFile sFile, sMoveTo
          Else
              FSO.CreateFolder(sMoveTo)
              'MsgBox "Folder " & sMoveTo & " created."
              FSO.MoveFile sFile, sMoveTo
              'MsgBox "File " & sFile & " moved to " & sMoveTo & "."
          End If
        oRst.MoveNext
Loop

End Function

'------------------------------/////////////// END






'/////////////////////////////////////////////////
'
'   Date Formatting function
'
'////////////////////////////////////////////////

Function pd(n, totalDigits) 
   If totalDigits > len(n) Then
       pd = String(totalDigits-len(n),"0") & n 
   Else 
       pd = n 
   End If 
End Function

'------------------------------/////////////// END

'/////////////////////////////////////////////////
'
'   Connection Sub
'
'////////////////////////////////////////////////

Sub ConnectDB()
Set oCon = CreateObject("ADODB.Connection")
Set oRst = CreateObject("ADODB.RecordSet")
Set oCmd = CreateObject("ADODB.Command")

With oCon
    .ConnectionString = "Provider=msidxs; Data Source = IncomingFax"
    .Open
End With

If oCon.State = 0 Then
    MsgBox "Connection failed."
WScript.Exit
End If

With oCmd
    .ActiveConnection = oCon
    .CommandText = sQry & "Where Contains('" & chr(34) & sString & chr(34) & "')"
    .CommandType = 1
End With

With oRst
    .CursorType = 3
    .CursorLocation = 3
    .LockType = 3
    .Open oCmd
End With

End Sub

'------------------------------/////////////// END

Their they sit to later be inserted into a document management program called Aquarius DMS.

I initially installed and was using the MODI (Microsoft Office Document Imaging) package on my file server to utilize the Tiff iFilter it included, but found that it wasn't finding everything I needed it to, so decided to try another iFilter made by Captaris. I was hoping to get better results in their OCR abilities over MODI's.

Unfortunately, the Captaris product didn't improve my results, so I switched back to MODI. No need to spend $300! Yay!

Reblog this post [with Zemanta]

Monday, June 08, 2009

Canon ImageRunner Job Accounting Setup

One of my clients required job accounting for an iR C2550 Canon printer. This is how I did it TM.

Step One : Set up printers on server

  1. Set up two printers on the server. One will be used for color, the other for B&W. Give them names that differentiate this.
  2. On the Security tab of the drivers, ensure that the Manage Printer ACL is not checked.
  3. B&W Specific Driver Settings:
    1. General Tab, Printing Preferences, Quality Tab, Color Mode is set to Black & White.
    2. Advanced Tab, Printing Defaults, Quality Tab, Color Mode is set to Black & White.
    3. Device Settings Tab, Job Accounting is checked.
    4. Device Settings Tab, Job Accounting, Settings, Allow Password Setting is checked, and 1000 is in the ID field. Password is blank. Do not use Job Accounting for B&W and Confirm Password when Printing are not checked.
  4. Color Specific Driver Settings:
    1. Quality steps 1 & 2 from above should default to Auto Detect. This should not be changed.
    2. Device Settings Tab, Job Accounting is checked.
    3. Device Settings Tab, Job Accounting, Settings, nothing should be checked or entered in any text boxes. Confirm Password when Printing should be checked and greyed out

Step Two : Set up printer through RUI

  1. Browse to printer at IP address.
  2. Select Add. Func. on left side navigation bar. Logon.
  3. Go to Department ID Management link.
  4. Under heading, locate green sparkling dot. This is the Department ID creation link. Click it.
  5. Create an ID of 1000 with no password. Check the following boxes, and ensure the page limits count is the default of 0:
    1. Total Color Prints
    2. Color Copy
    3. Color Print
  6. Click Ok. This just created a department that has unrestricted access to B&W copies and print jobs, no password required.
  7. Repeat step 5 to create a new Department ID.
  8. Give your new Department ID a password. No other settings are required for this ID, as no restrictions will be imposed.
  9. Click Ok. This just created a department that can only print or copy color documents with a user id and password, whether printing from a desktop PC, or at the printer console.
  10. In the main Department ID Management area, click the Settings button in the upper right corner.
  11. Check the Enable Department ID Management box.
  12. The following should not be checked:
    1. Any of the Limit Functions.
    2. Allow Printer Jobs with Unknown IDs
  13. The following SHOULD be checked:
    1. Allow Remote Scan Jobs with Unknown IDs
    2. Allow Black Copy/Inbox Print Jobs
    3. Allow Black Printer Jobs

Step Three : Set up workstations

  1. Delete any local printers referencing the iR2550.
  2. Go to Start, Run, and type \\PRINTSERVER in the box, where PRINTSERVER is your print server NetBios name. Click Ok.
  3. Right-click the CanonColor and select Connect. Do the same for CanonB&W.
  4. Open Printers and Faxes on the local PC.
  5. Right-Click the new B&W printer and select Properties.
  6. General Tab, Printing Preferences, Quality Tab, Color Mode is set to Black & White.
  7. Advanced Tab, Printing Defaults, Quality Tab, Color Mode is set to Black & White
  8. Device Settings Tab, Job Accounting is checked
  9. Device Settings Tab, Job Accounting, Settings, Allow Password Setting is checked, and 1000 is in the ID field. Password is blank. Do not use Job Accounting for B&W and Confirm Password when Printing are not checked.
  10. Test print a B&W document to the B&W printer. No popup should appear.
  11. Test print a Color document to the Color printer. You should be prompted with an ID and password. Supply one, and ensure it prints.

Troubleshooting

If printing fails completely;

  1. Open the workstations Printers and Faxes control panel.
  2. Delete the iR2550 printers.
  3. Select File, Server Properties.
  4. On the Drivers tab, locate the 2550.
  5. Highlight it and select Delete.
  6. Click Ok.
  7. Re-install the printers.
Reblog this post [with Zemanta]

Wednesday, June 03, 2009

Add Google Analytics code to Efficon Articles module

My employer, IHBSOnline.com, uses the Efficon Articles 3.x module in DotNetNuke to aid in driving website traffic.

Every morning, I troll the news sites, and add News content items to the module. Then I use Twitter to announce these additions. I can easily browse to the posts and see the number of hits these items generate.

Image representing Google Analytics as depicte...Image via CrunchBase

I also use the iFinity Google Analytics module to track my web traffic. Unfortunately, you can't add this module to any post, since technically, it's not really a page.

I played around a bit, and found that I was able to add my code to the DesktopModules/Articles/ArticleDetailsStandard.aspx, and start tracking my posts!

Reblog this post [with Zemanta]

Canon iR C2880 Debian UFR and Postscript drivers

I've always disliked the fact that I couldn't print to our Canon iR C2880 in color. It's not got the postscript option, which had I known how difficult it would have been for non-Windows PC's to use it, I would have investigated that option.
They advertise the fact that the folks at Codehost, Inc. make a product called BrightQ that will print to these machines, but I never got it working well on my SuSE distribution.
Ubuntu wordmark officialImage via Wikipedia
I just recently updated my desktop from SuSE Linux Desktop Enterprise 10.1 to Ubuntu 9, and I've not been more pleased, but STILL couldn't print in color to our Canon...until now.
I found a thread about this subject here where a kind soul named Andy informed the board that Canon Australia released Linux UFR and Postscript drivers in Deb, RPM, and source (link updated 7/29/2013)!
According to the documentation, the following Canon printers are supported:
  • LBP3360
  • LBP3370
  • LBP3460
  • LBP5360
    Canon Inc.Image via Wikipedia
  • LBP5960
  • LBP5970/5975
  • iR1018/1022/1023
  • iR105+
  • iR2016/2016i
  • iR2018/2018i
  • iR2020/2020i
  • iR2022/2025/2030
  • iR2230
  • iR2270/2870
  • iR2830
  • iR3025
  • iR3030
  • iR3035/3045
  • iR3225/3225N
  • iR3230/3230A/3230N
  • iR3235/3235A/3235N/3245/3245A/3245N
  • iR3530
  • iR3570/4570
  • iR4530
  • iR5055/5065
  • iR5075
  • iR5570/6570
  • iR7086/7095/7095P/7105
  • iR8070
  • iR85+
  • iR9070
  • iR C2380i/C2550/C2550i
  • iR C2580i
  • iR C2880/C2880i/C3380/C3380i
  • iR C3080/C3080i/C3580/C3580i
  • iR C3180/C3180i
  • iR 3180C/3180Ci
  • iR C4080/C4580
  • iR C5180
  • iR C5185
  • iR C5870/C6870
  • iR C5880/C5880i/C6880/C6880i
  • iR 5880C/5880Ci/6880C/6880Ci
  • imagePRESS C1
  • MF4010
  • MF4100 Series
  • MF4270
  • MF4600 Series
  • MF6530/6540PL/6550/6560PL/6570/6580PL
  • MF7170i
  • L90/160/230
  • LC800/L3000
I found that my Ubuntu installation was missing libcupsys2, which was easily remidied by issuing 'sudo apt-get install libcupsys2'. I was then able to use the Gdebi Package installer by right-clicking the .deb packages and choosing that option.
If you aren't using Ubuntu, read the release notes included. There are MANY issues listed for Mandravia, SuSE, Fedora, and Debian.
I ran a test print, et voila, it came out in color!
Enhanced by Zemanta