Unanswered: How to execute a Unix Shell command from a remote Windows application
We have an ERP system running on Compaq Tru64 UNIX V5.1A (Rev. 1885).
I am able to run ERP commands (Macro recorded script files to invoke e.g. the invoice process) from the Unix command shell.
To automise this, I'd like to run these commands from a remote Windows application e.g. SQL Server (with VB Scripts).
Does anyone have an idea how to do this?
This is commonly done by SSH (e.g. http://www.chiark.greenend.org.uk/~sgtatham/putty/), rsh, or rexec. The latter two are included with Windows but are typically frowned upon (or disallowed altogether) by system administrators because of security concerns.
"It does not work" is not a valid problem statement.
Lets assume that you have some common directory/folder, using either NFS or Samba, or even ftp.
On the Windows side have the application create a request file containing named pairs as:
APPLICATION=invoicing\; export APPLICATION
DATE=20090915\; export DATE
NAME="John Doe"\; export NAME
The back slashes are required to escape any unix meta characters. The quotes are required for variables with embedded spaces. Do not leave any white space around the equal sign.
edit: On second reading, the backslashes will not be required unless a unix meta character is embedded within the variable value, such as NAME="Michael O\'Connor"; export NAME :edit
Save the file in the common directory, known as "/u/spool/in" on the unix side.
On the unix side, write a script like the following:
if [ -r lock.file ]
echo `cat $lock.file` is still running >log.file edit: probably should be >>
echo $$ >lock.file
for file in $list
echo $APPLICATION $DATE $NAME >>log.file
mv /u/spool/in/$file /u/spool/out
Add a routine to /etc/rc2.d to clear any lock files on system start up.
Add a second file to the out folder showing the results of the process.
The windows file will probably have carriage returns and line feeds at the end of each line. If this becomes a problem, use 'tr -d "\r" <infile >outfile' to eliminate them (or dos2unix if you have that)
If you use ftp to transfer the file, send two files for each request, the first containing the data as above, the second as a semaphore file to say that the transfer is complete. Unix will see the text file as soon as it is opened for writing, and may try to process it before the transfer is complete.
edit: When creating a file naming convention, consider the possibility of duplicates, and the options available for the ls command so that jobs are processed in the desired sequence.