If you can call it from the OS/shell command line, you can schedule it into your Job2Do batch! Here we try to list some commands, command sequences, short scripts, and command line tools that you may find useful to schedule in a Job2Do batch. The focus is on Windows, since most experienced UNIX users will already have access to tremendous command line power and be familiar with exploiting it.
This page is a work in-
These samples are just starting points. Automators should refer to proper scripting
manuals to create production-
Command Links
Resources
First, try using Job2Do’s built-
perl -
mv myfile.txt myfile.`date "+%Y%m%d.%H.%M.%S"`.txt
' get leaf name
filename = wscript.arguments(0)
set fso = CreateObject("Scripting.FileSystemObject")
leafname = fso.GetFile( filename ).Name
' split leafname at first occurence of period
baselen = InStr( leafname, "." )
base = Left( leafname, baselen-
sufflen = Len( leafname ) -
suff = Right( leafname, sufflen )
' create datestamp
tmp= now()
yyyymmdd = DatePart("yyyy",tmp) & Right("00" & DatePart("m",tmp),2) & Right("00" & DatePart("d",tmp),2)
' rename file inserting datestamp before first occurrence of period
set fso = CreateObject("Scripting.FileSystemObject")
fso.GetFile( filename ).Name = base & "." & yyyymmdd & "." & suff
cscript c:\vbscripting\datestamp.vbs c:\folder\myfile.txt
Process Killing
Whichever OS you’re working on, you’ll need to be sure you only have a single process
with the given image name. On UNIX, use a combination of ps and kill in a shell script
(syntax/output of ps is OS-
cmd /c "taskkill /IM myprocess.exe /F"
Unix tar and gzip are indispensable tools for archiving and compression. We will
not attempt to document these already well-
7z a -
The commercial tool WinZip© (http://www.winzip.com) also offers command line access.
Job2Do’s plug-
Job 1 (“parent” job) -
To call a VBA macro in a Microsoft Excel spreadsheet from Job2Do do the following:
Assuming you have set up Auto_Open() correctly in your spreadsheet, your command would look like the following. Your full path to the Excel.exe binary may differ. You do not need to quote around spaces in the path:
Shells and Scripting Engines
Each OS, shell, or scripting engine needs to be called differently from within a Job2Do text command. The key point to remember is that in Windows Job2Do calls the OS directly, whereas on UNIX/Mac Job2Do calls the shell that is configured for the Client. Therefore:
On Windows, binaries, assuming they are on your path, can be called directly while all other scripts should be called using the appropriate scripting engine.
On UNIX/Mac, just go ahead and call the command as you would type it in the shell.
Note that plug-
The table below gives a few examples of how to call different targets on Windows:
Windows Links
Free command line scriptable archiver.
Serve up *NIX files on a Windows network.
Perl for Windows.
Resources for scripting Outlook.
Outlook scripting security patch workaround.
Good site for Windows scripting resources.
Microsoft’s official reference.
Microsoft’s official site.
On Windows, if you wanted a specific date format, for example YYYYMMDD, you could first create a script just as the following:
Assuming you place the above script into a VBScript file called “datestamp.vbs”, then call from Job2Do’s command line as follows:
echo "cd outbound
get data_file_from_customer.csv" > /tmp/my_sftp_commands.bat
cd /home/user/customer_file_download_area; sftp -
C:\Program Files\Microsoft Office\OFFICE11\excel.exe /e F:\batch_spreadsheets\myspreadsheet.xls
Copyright © 2010 Sypsoft, LLC. All rights reserved. |
Job 2 (“child” job) -
Another way to call a macro would be by using a VBScript wrapper to call Excel. However, this method is a little harder to support than the method above, because by using a wrapper you introduce another operating system process. The Excel.exe process will be a child process of the VBScript process, which is the only process that Job2Do will “know” about. Therefore, killing the job from Job2Do would only kill the VBScript process, and you would be left with an Excel “zombie” process on the client machine.
Command Target |
Calling Example (text in Job2Do command field) |
Comments |
Windows Binary |
mytool.exe /a /b /c |
...where /a /b /c are command line switches. Make sure that mytool.exe is in you path, or use the full path when calling. |
DOS Command |
cmd /c copy file1 file2 |
Job2Do does not wrap commands in a shell by default. Calling “cmd /c ...” executes the following command and arguments in a new DOS shell. |
VBScript |
cscript myscript.vbs |
Generally batch jobs should run in the background, so avoid using wscript. |
VBA Macro (in Excel) |
excel.exe /e myspreadsheet.xls |
See XL VBA Macro Calling below. |
Perl Script |
perl myscript.pl |
Assuming you have installed some version of Perl and placed it in your path. |
Or, if you have perl installed, try the command line script below (replace “c:/myfile.txt” with file to watch). The command below is quoted and escaped for Windows and may need to be modified to run in a specific UNIX shell:
' use first arg as full pathname of a file
fn = Wscript.arguments(0)
Wscript.Echo "Looking for file '" & fn
Set objFSO = CreateObject("Scripting.FileSystemObject")
' loop until file exists
found = 0
While found = 0
If objFSO.FileExists( fn ) Then
Wscript.Echo "Found file."
found = 1
Else
Wscript.Echo "File does not exist. Sleeping..."
Wscript.Sleep 5000
End If
Wend
Wscript.Echo "Done."
cscript c:\vbscripting\fileWatch.vbs f:\FileDrop\foo.txt
Assuming you place the above script into a VBScript file called “fileWatch.vbs”, then call from Job2Do’s command line as follows:
Other useful VBScript file manipulation scripts can be found here (external link):
http://www.cruto.com/resources/vbscript/vbscript-
While some of the commands listed below can be performed with Job2Do’s built-
In general, assuming you have the correct shell or scripting engine installed, the code examples below can be cut/pasted directly into the “Command:” text area of your Job2Do job definitions and then modified to your needs. When code should first be placed in a separate script file and then called from the job command, it is noted below.
Disclaimer: The examples listed here are for informational purposes only. All use of code examples or modified code examples are at the user’s own risk. Sypsoft does not warranty the functionality or correctness of any code provided here.
Home |
Job2Do |
Contact Us |
About Sypsoft |
|
Architecture |
Feature Set |
FAQ |
Resources |
Forums |
Download |