+ Post New Thread
Results 1 to 5 of 5
*nix Thread, Batch files for ssh/linux... in Technical; Hi. Does anyone know of a way to run a script that'll auto connect to a server via SSH (smoothwall), ...
  1. #1

    Join Date
    Nov 2007
    Posts
    554
    Thank Post
    3
    Thanked 3 Times in 3 Posts
    Rep Power
    16

    Batch files for ssh/linux...

    Hi.
    Does anyone know of a way to run a script that'll auto connect to a server via SSH (smoothwall), login and then perform a few commands, then close the SSH session.

    Thanks in advance all. .

  2. #2

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,842
    Thank Post
    110
    Thanked 592 Times in 513 Posts
    Blog Entries
    1
    Rep Power
    226
    First off, you need to swap ssh keys with the remote system so you can login without a password prompt.

    HOWTO: set up ssh keys

    At that point you can either run a single SSH command to run the script on the remote system.

    Code:
    ssh user@system /usr/bin/somescript.sh
    Or run the commands over SSH one after the other.

    Code:
    ssh user@system /usr/games/fortune | /sbin/wall
    ssh user@system /sbin/reboot

  3. Thanks to Geoff from:

    tom_newton (13th November 2008)

  4. #3

    Join Date
    Feb 2006
    Location
    Derbyshire
    Posts
    1,381
    Thank Post
    181
    Thanked 211 Times in 171 Posts
    Rep Power
    65
    If you mean from Windows to the Linux machine, I'd just do it with PLink the command line driven aspect of Putty...

    Using the command-line connection tool Plink

    Should do everything quite happily.

  5. 2 Thanks to OutToLunch:

    tom_newton (13th November 2008), webman (12th November 2008)

  6. #4

    dhicks's Avatar
    Join Date
    Aug 2005
    Location
    Knightsbridge
    Posts
    5,688
    Thank Post
    1,271
    Thanked 791 Times in 688 Posts
    Rep Power
    238
    Quote Originally Posted by boomam View Post
    Does anyone know of a way to run a script that'll auto connect to a server via SSH (smoothwall), login and then perform a few commands, then close the SSH session.
    As pointed out above, on Windows plink connecting with a key file should do it. I've actually had occasion to write a utility that does pretty much what you describe above, for which I used Python:

    Code:
    for fileLine in os.popen("PuTTY\\plink -batch -i PuTTY\\xenConsole.ppk root@" + dirName + " cat /proc/mdstat").readlines():
    	line = fileLine[:-1]
    	reResult =  re.search(" *(.*) blocks \[(.*)/(.*)\] \[(.*)\]", line)
    	if reResult:
    		RAIDState = reResult.group(4)

    The above connects to the server and gets the state of the mdadm RAID array, sorting through the answer with a regular expression to parse out the data needed.

    --
    David Hicks

  7. Thanks to dhicks from:

    tom_newton (13th November 2008)

  8. #5


    tom_newton's Avatar
    Join Date
    Sep 2006
    Location
    Leeds
    Posts
    4,485
    Thank Post
    867
    Thanked 854 Times in 675 Posts
    Rep Power
    197
    Thanks for the answers folks... now I am wondering what the OP was wanting and how we might officially support what he's after?



SHARE:
+ Post New Thread

Similar Threads

  1. Rename a batch of files all at once.
    By Kyle in forum How do you do....it?
    Replies: 10
    Last Post: 19th November 2009, 07:31 AM
  2. Running batch files in vista
    By Kained in forum Windows Vista
    Replies: 6
    Last Post: 4th September 2007, 03:25 PM
  3. numbers and batch files
    By russdev in forum Windows
    Replies: 4
    Last Post: 19th November 2005, 10:51 PM
  4. Blocking Batch Files using Group Policy in Server 2003
    By markwilliamson2001 in forum Windows
    Replies: 13
    Last Post: 4th October 2005, 06:28 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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