'Very basic and unsecure proc to print at IHS Vienna 'without being in the network (i.e. yellow cable) 'Needs to have Plink installed -> I.e. just install PuTTY (standard version) and you're done 'By Stefan Zeugner 2007 '######### SETTINGS ################# Const sServer="elaine.ihs.ac.at" 'FTP and SSH Server Const sUsername="YOURUSERNAME" Const sPwd="YOURPASSWORD" Const sPrinter="ljsfg2nb" 'Printer name such as ljedu1 '----- OPTIONAL -------- Const sPrintOptions="" 'Optional: You may include the printing options ? that are with the unix command "lpr ? filename.ext", such as "-K2" for two copies Const sOtherUnixCommands="" 'Optional: You may include unix commands here that are executed prior to printing '#################################### 'Basic Struct: FTP the PDF to the unix server, then via plink convert it to PS and print it Dim FileName Dim Path Dim Extension Dim File If WScript.arguments.length=0 Then sFullPath=GetFileName() else sFullPath=cstr(WScript.arguments(0)) End If if sFullPath="" Then WScript.Quit zSplitPath(cstr(sFullPath)) DIM fso, FtpFile, BatchFile, PlinkFile ' Create input file for Win Batch "ftp -s:" Set fso = CreateObject("Scripting.FileSystemObject") Set FtpFile = fso.CreateTextFile("ftpstuff.txt", True) FtpFile.WriteLine("open " & sServer) FtpFile.WriteLine(sUsername) FtpFile.WriteLine(sPwd) FtpFile.WriteLine("binary") FtpFile.WriteLine("put """ & sFullPath & """") FtpFile.WriteLine("bye") FtpFile.Close set fso = Nothing ' Create input file for Plink Set fso = CreateObject("Scripting.FileSystemObject") Set PlinkFile = fso.CreateTextFile("plinkcmds.txt", True) PlinkFile.WriteLine("PRINTER=" & sPrinter) PlinkFile.WriteLine(sOtherUnixCommands) If LCase(Extension) = "pdf" Then PlinkFile.WriteLine("pdftops """ & File & ".pdf""") PlinkFile.WriteLine("lpr " & sPrintOptions & " """ & File & ".ps""") PlinkFile.WriteLine("rm """ & File & ".pdf""") PlinkFile.WriteLine("rm """ & File & ".ps""") Else PlinkFile.WriteLine("lpr " & sPrintOptions & " """ & FileName & """") PlinkFile.WriteLine("rm """ & FileName & """") End If PlinkFile.WriteLine("exit") PlinkFile.Close() set fso = Nothing ' Create Bat doing ftping and plinking Set fso = CreateObject("Scripting.FileSystemObject") Set BatchFile = fso.CreateTextFile("ftpprinter.bat", True) BatchFile.WriteLine("ftp -s:ftpstuff.txt") BatchFile.WriteLine("set PATH=%ProgramFiles%\PuTTy\;%PATH%") BatchFile.WriteLine("echo " & sPwd & " | plink -m plinkcmds.txt " & sUsername & "@" & sServer) BatchFile.WriteLine("del ftpstuff.txt") BatchFile.WriteLine("del plinkcmds.txt") BatchFile.WriteLine("del ftpprinter.bat") BatchFile.Close Set oShell = CreateObject("WScript.Shell") oShell.Run "ftpprinter.bat" Set oShell=Nothing 'Clean up 'If fso.FileExists("ftpprinter.bat") Then ' fso.DeleteFile "ftpprinter.bat" 'End If set fso = Nothing WScript.Quit Function GetFileName() Set objShell = CreateObject("WScript.Shell") strPathDesktop = objShell.SpecialFolders("Desktop") Set objShell = Nothing Set objDialog = CreateObject("UserAccounts.CommonDialog") objDialog.Filter = "PDF|*.pdf|PS|*.ps|PRN|*.prn|All Files|*.*" objDialog.FilterIndex = 1 objDialog.InitialDir = strPathDesktop intResult = objDialog.ShowOpen If intResult = 0 Then GetFileName="" Else GetFileName=objDialog.FileName End If End Function Private Sub zSplitPath(FullPath) Dim nPos nPos = InStrRev(FullPath, "\") If nPos Then If Left(FullPath, 2) = "\\" Then If nPos = 2 Then Drive = FullPath Path = "" FileName = "" File = "" Extension = "" Exit Sub End If End If Path = Left(FullPath, nPos - 1) FileName = Mid(FullPath, nPos + 1) nPos = InStrRev(FileName, ".") If nPos Then File = Left(FileName, nPos - 1) Extension = Mid(FileName, nPos + 1) Else File = FileName Extension = "" End If Else Path = FullPath FileName = "" File = "" Extension = "" End If If Left(Path, 2) = "\\" Then nPos = InStr(3, Path, "\") If nPos Then Drive = Left(Path, nPos - 1) Else Drive = Path End If Else If Len(Path) = 2 Then If Right(Path, 1) = ":" Then Path = Path & "\" End If End If If Mid(Path, 2, 2) = ":\" Then Drive = Left(Path, 2) End If End If End Sub