Find the answer to your Linux question:
Results 1 to 5 of 5
Hi all, I am trying to write a script which login to a remote machine and executes some command, wait till they are executed and continue processing the current script. ...
  1. #1
    Just Joined!
    Join Date
    Jun 2007
    Posts
    4

    Executing the script in Remote System

    Hi all,

    I am trying to write a script which login to a remote machine and executes some command, wait till they are executed and continue processing the current script. I am not able to do this.

    #This is the way i tried

    if [#1 eq qa] ; then

    sudo su xyz@ax01.xyz.com

    cd /test/script

    ./runtheScript


    fi

    But when i try to execute the above script. It gives me an error that the script is not found. Also how could i sepecify the password for the xyz user so that he could log on sucessfully. I also want to know whether the command executing in the remote is finished? Can anyone help me in writing the script. Thanks in Advance.

    Regards,
    Arul.

  2. #2
    tpl
    tpl is offline
    Linux User
    Join Date
    Jan 2007
    Location
    cleveland
    Posts
    452
    have you considered kermit?

    the communications package (from Columbia University) has a very
    powerful scripting language designed precisely to automate such
    doings as you suggest: logging in remotely, giving passwords,
    running programs remotely, downloading the results &c

    for linux, you want "C-kermit"
    the sun is new every day (heraclitus)

  3. #3
    Linux Enthusiast
    Join Date
    Jul 2005
    Location
    Maryland
    Posts
    521
    You can use "expect" to do what you want.
    You will probably have to install it first:
    Code:
    yum install expect
    or
    Code:
    apt-get install expect
    depending on your distro.

    However, a better way would be to setup SSH server and use public key authentication as Thrillhouse suggested here

  4. #4
    Just Joined!
    Join Date
    Jun 2007
    Posts
    4
    Thanks a lot. Will try it out.

    Regards,
    Arul.

  5. #5
    Linux Enthusiast KenJackson's Avatar
    Join Date
    Jun 2006
    Location
    Maryland, USA
    Posts
    506
    As noted, I believe SSH is the ideal solution. And using keychain allows you to only type in your passphrase once per login.

    Currently, I routinely execute commands like this:
    Code:
    ssh webhost 'cd public_html; ls -l'
    I also have entries in my ~/.ssh/config file so ssh knows what username to use on the remote host.

Posting Permissions

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