Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

running commands from local bash script on remote machine

  • 16-03-2009 12:25PM
    #1
    Registered Users, Registered Users 2 Posts: 528 ✭✭✭


    Hi All,

    I have a script on my local machine. When I run the script it opens up Putty and connects to a remote location through ssh. Now the problem I am having is then running commands from my local script in the remote location. No matter what I seem to try in the script nothing seems to happen in the remote console. Its probably something relatively easy that I am missing here but I have looked up a few things on the web and nothing seems to work for me.

    All I basically want to do is ssh from my current location to another one and then change into the relevant directory on the new console and then run a script that is stored in the remote location. The output of this script then creates some files that I then want to save/transfer back on my local machine.


    Any advice would be greatly appreciated.

    Thanks in advance,
    Eoin


Comments

  • Closed Accounts Posts: 1,444 ✭✭✭Cantab.


    Please post the script.


  • Registered Users, Registered Users 2, Paid Member Posts: 2,427 ✭✭✭ressem


    1) ssh from my current location to another one
    2) and then change into the relevant directory on the new console
    3) and then run a script that is stored in the remote location.
    4) The output of this script then creates some files that I then want to save/transfer back on my local machine.

    In your script are you using putty.exe or putty's plink.exe program?

    Something like

    plink user@host "cd mydirectory; ./myscript "
    pscp -batch user@host:/home/user/mydirectory/myoutput c:\temp


  • Registered Users, Registered Users 2 Posts: 528 ✭✭✭ridonkulous


    Im using putty.exe


  • Registered Users, Registered Users 2 Posts: 528 ✭✭✭ridonkulous


    Sorry I can't put up the script as it contains nothing but sensitive data but I just realised its not the script that is the problem its running the commands in putty that seems to be causing the problem. Im just googling some stuff now but I haven't found a solution yet. If anyone can help me out or has knowledge of running scripts through Putty I would be extremely grateful. Basically all I have working at the minute is the execution of putty and the putty login. The remainder of the script then does not run in putty but when I end the putty session the script attempts to run on my local machine.


  • Registered Users, Registered Users 2, Paid Member Posts: 2,427 ✭✭✭ressem


    Putty's plink.exe and pscp?

    http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html


    plink is the console version of putty for non-interactive logins.
    http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter7.html#plink

    pscp is the remote file transfer over ssh application.
    http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter5.html#pscp


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 528 ✭✭✭ridonkulous


    Thanks for that Im using plink now and some of the stuff is now working as expected. I do still have one problem when I attempt to ssh into another console but its more a syntax problem more than anything else I think. Thanks again.


Advertisement