Welcome, Register for free! or Login below:
EduGeek.net RSS Feeds Register FAQ Members Social Groups User Map Calendar Search Today's Posts Mark Forums Read

*nix

*nix forum sponsored by
*nix Forum Sponsored by Navaho

Powering the backend of many of our networks, unbeknown to many. Linux, Solaris, Unix...

Go Back   EduGeek.net Forums > Technical > *nix
Reply
 
LinkBack Thread Tools Search Thread
Sponsored Links
Old 12-11-2008, 12:44 PM   #1
 
boomam's Avatar
 
Join Date: Nov 2007
Posts: 543
uk
Thanks: 2
Thanked 3 Times in 3 Posts
Rep Power: 5 boomam is on a distinguished road
Send a message via MSN to boomam
Default 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. .
  Reply With Quote
Old 12-11-2008, 12:53 PM   #2
 
Geoff's Avatar
 
Join Date: Jun 2005
Location: Fylde, Lancs, UK.
Posts: 10,469
uk uk lancashire
Thanks: 55
Thanked 339 Times in 292 Posts
Blog Entries: 1
Rep Power: 89 Geoff has a brilliant futureGeoff has a brilliant futureGeoff has a brilliant futureGeoff has a brilliant futureGeoff has a brilliant futureGeoff has a brilliant futureGeoff has a brilliant futureGeoff has a brilliant futureGeoff has a brilliant futureGeoff has a brilliant futureGeoff has a brilliant futureGeoff has a brilliant future
Send a message via ICQ to Geoff Send a message via AIM to Geoff Send a message via MSN to Geoff Send a message via Yahoo to Geoff Send a message via Skype™ to Geoff
Default

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
  Reply With Quote
The Following User Says Thank You to Geoff For This Useful Post:
tom_newton (13-11-2008)
Old 12-11-2008, 01:08 PM   #3
 
OutToLunch's Avatar
 
Join Date: Feb 2006
Location: Derbyshire
Posts: 1,007
uk
Thanks: 57
Thanked 111 Times in 99 Posts
Rep Power: 32 OutToLunch is a splendid one to beholdOutToLunch is a splendid one to beholdOutToLunch is a splendid one to beholdOutToLunch is a splendid one to beholdOutToLunch is a splendid one to beholdOutToLunch is a splendid one to beholdOutToLunch is a splendid one to behold
Default

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.
  Reply With Quote
The Following 2 Users Say Thank You to OutToLunch For This Useful Post:
tom_newton (13-11-2008), webman (12-11-2008)
Old 12-11-2008, 05:41 PM   #4
 
dhicks's Avatar
 
Join Date: Aug 2005
Location: Alton, Hampshire
Posts: 2,142
uk
Thanks: 245
Thanked 202 Times in 172 Posts
Rep Power: 54 dhicks has much to be proud ofdhicks has much to be proud ofdhicks has much to be proud ofdhicks has much to be proud ofdhicks has much to be proud ofdhicks has much to be proud ofdhicks has much to be proud ofdhicks has much to be proud ofdhicks has much to be proud of
Default

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
  Reply With Quote
The Following User Says Thank You to dhicks For This Useful Post:
tom_newton (13-11-2008)
Old 13-11-2008, 11:25 AM   #5
 
tom_newton's Avatar
 
Join Date: Sep 2006
Location: Leeds
Posts: 1,486
uk uk yorkshire
Thanks: 77
Thanked 139 Times in 109 Posts
Rep Power: 32 tom_newton is a splendid one to beholdtom_newton is a splendid one to beholdtom_newton is a splendid one to beholdtom_newton is a splendid one to beholdtom_newton is a splendid one to beholdtom_newton is a splendid one to beholdtom_newton is a splendid one to behold
Default

Thanks for the answers folks... now I am wondering what the OP was wanting and how we might officially support what he's after?
  Reply With Quote
Reply
Similar Threads
Thread Thread Starter Forum Replies Last Post
Running batch files in vista Kained Windows Vista 6 04-09-2007 02:25 PM
Rename a batch of files all at once. Kyle How do you do....it? 8 27-08-2006 08:59 PM
numbers and batch files russdev Windows 4 19-11-2005 09:51 PM
Blocking Batch Files using Group Policy in Server 2003 markwilliamson2001 Windows 13 04-10-2005 05:28 PM



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search Thread
Search Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:20 AM.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.0 ©2009, Crawlability, Inc.
Copyright EduGeek.net




website uptime

© 2005 - 2009 EduGeek.net
no new posts