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

    Join Date
    Mar 2010
    Posts
    24
    Rep Power
    0

    Shell script that logs into another machine and executes some commands


    Hello, I am trying to write a script that connects to a server and executes some commands on there. Something like this:

    #!/bin/sh

    telnet remote_machine
    cd /home/some_directory
    cat a_file_in_current_directory


    Unfortunately after login/password I guess the script doesn't jump past the telnet command, until I exit. What do I need to do to make the script start executing commands in the remote shell?
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,430
    Rep Power
    4539
    Use ssh instead of telnet and you can do most anything you need on the remote machine.

    Comments on this post

    • SimonJM agrees : ssh is the way to go as Doug says
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester

IMN logo majestic logo threadwatch logo seochat tools logo