boomam Posted November 12, 2008 Posted November 12, 2008 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. .
Geoff Posted November 12, 2008 Posted November 12, 2008 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. ssh user@system /usr/bin/somescript.sh Or run the commands over SSH one after the other. ssh user@system /usr/games/fortune | /sbin/wall ssh user@system /sbin/reboot 1
OutToLunch Posted November 12, 2008 Posted November 12, 2008 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. 2
dhicks Posted November 12, 2008 Posted November 12, 2008 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: 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 1
tom_newton Posted November 13, 2008 Posted November 13, 2008 Thanks for the answers folks... now I am wondering what the OP was wanting and how we might officially support what he's after?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now