#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2011
    Posts
    6
    Rep Power
    0

    Triggering remote unix shell script from Windows Batch file


    Hi,
    I've been trying (unsuccessfully) to trigger a shell script stored on a remote unix server from my windows using a bat file.

    Some of my attempts so far:

    D:\putty.exe -load server -l user -pw password -m D:\cmd.txt

    The cmd.txt contains the command to trigger the script.
    When I run the above bat file, the unix session opens and closes abruptly.

    I also tried using plink:
    plink.exe user@server -pw password -m cmd.txt

    but this won't work either. Any suggestions?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,450
    Rep Power
    1751
    Looking at the docs it looks like plink would be the way to go (if using putty).
    The suggestions of how to go about testing the connection on that page seem to be well done so I won't attempt to duplicate them!
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2011
    Posts
    6
    Rep Power
    0
    Hi again,
    After going through the information given in the link I wrote the following command which I believe is syntactically correct:

    plink -ssh -pw xxxx user@server -m cmd.txt

    However, on execution I get the following error:

    @----------------------------------------------------------@
    | PLINK! | v1.07 | 10/Aug/2009 |
    |----------------------------------------------------------|
    | (C) 2009 Shaun Purcell, GNU General Public License, v2 |
    |----------------------------------------------------------|
    | For documentation, citation & bug-report instructions: |
    | @----------------------------------------------------------@

    Web-based version check ( --noweb to skip )
    Recent cached web-check found... OK, v1.07 is current

    Writing this text to log file [ plink.log ]
    Analysis started: Tue Sep 06 12:50:59 2011

    ** Unused command line option: -ssh
    ** Unused command line option: -pw
    ** Unused command line option: xxxx
    ** Unused command line option: user@server
    ** Unused command line option: -m
    ** Unused command line option: cmd.txt

    ERROR: Problem parsing the command line arguments.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,450
    Rep Power
    1751
    That is not the plink that is part of the putty toolset. A quick google suggests it is something entirely else, which woudl help explain things!
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2011
    Posts
    6
    Rep Power
    0
    Yup it's working! Just plain stupid of me. Thanks a lot Simon
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,450
    Rep Power
    1751
    Glad it's working.
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2011
    Posts
    6
    Rep Power
    0
    Hi Simon,
    Just wondering if I can do this using putty instead of plink. The reason for this is once I connect to the remote unix server I have to ssh to another server and there I need to run a shell script. with plink i'm unable to use ssh probably because the dos shell is not supported or something so it might work if I use putty.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,450
    Rep Power
    1751
    Good question - not something I have ever tried, but the I have never used plink either!
    It looks like you may be able to do something with putty, using the -m parameter and supplying a command - but then that would just be what plink does.
    I suspect, from what you have said, you might be able to start a command line session to Server A with plink, run a command (either directly or imbedded in a script) that uses ssh to run another command on Server B (ssh user@host "command to run").
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc

IMN logo majestic logo threadwatch logo seochat tools logo