Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2004
    Location
    Haaksbergen, Netherlands
    Posts
    69

    Exclamation Unanswered: How to execute a Unix Shell command from a remote Windows application

    Hi,

    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?

    Thanks in advance,

    Wim Venema
    Last edited by Wim Venema; 09-07-09 at 16:40.

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    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.

  3. #3
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    You might also consider having the VB Script create a set of instructions for a Unix cron job to process, and drop the VBS instructions into a shared folder/directory

  4. #4
    Join Date
    Jun 2004
    Location
    Haaksbergen, Netherlands
    Posts
    69
    Hi Kitaman,

    Can you please provide me with examples?

    Thanks in advance,

    Wim

  5. #5
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    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:

    !#/bin/ksh
    if [ -r lock.file ]
    then
    echo `cat $lock.file` is still running >log.file edit: probably should be >>
    exit 1
    fi
    echo $$ >lock.file
    list=`ls /u/spool/in`
    for file in $list
    do
    . /u/spool/in/$file
    echo $APPLICATION $DATE $NAME >>log.file
    my_real_process
    mv /u/spool/in/$file /u/spool/out
    done
    rm lock.file

    Some caveats:
    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.


    Jack
    Last edited by kitaman; 09-17-09 at 07:46.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •