Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 04-03-2006, 06:02 PM   #1
LQ Newbie
Registered: Mar 2006
Location: England
Distribution: RedHat 9
Posts: 16

Rep: Reputation: 0
can ssh execute multiple commands at the same time?

i am using ssh to connect to remote hosts on a network to monitor activity. is it possible to execute multiple commands on the same line? for example?

foreach $host (@hosts) {

print FH "<H3><A NAME\=\"$host\">$host\</A\></H3>";
print FH "<P>";

$cmd="hostname;vmstat;top -n 1 | head -n;df -k";

foreach $host (@hosts) {

print FH "<TABLE BORDER=0>";

@result=`ssh $host -l root -K $cmd`;

foreach $line (@result) {

if ( $line =~/9[0-9]\%\s*\>\// ) {


print FH "<TR><TD> <A NAME\=\"$count\"><FONT


im a bit lost here, it carries out the first command on the remote machine but then it carries out the remaining commands on the host machine that is running the perl script.

thanx in advance, Singist
Old 04-03-2006, 07:25 PM   #2
Registered: Feb 2004
Location: Outermost mingetty
Distribution: RHEL3,RH4U4,Sol9, Sol10
Posts: 321

Rep: Reputation: 31
Don't you already have a thread open on this?
Old 04-04-2006, 10:14 AM   #3
Registered: Jun 2005
Location: Odenton, MD
Distribution: Gentoo
Posts: 290

Rep: Reputation: 30
Poor form: Put everything on the same line. Better form: put a "\" before each new line.


Thread Tools Search this Thread
Search this 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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to execute multiple commands with find and -exec... tomstratton Linux - General 6 05-26-2009 04:26 AM
LXer: Execute commands simultaneously on multiple servers LXer Syndicated Linux News 0 02-20-2006 12:31 PM
LXer: Execute Commands on Multiple Linux or UNIX Servers LXer Syndicated Linux News 0 12-27-2005 07:46 PM
execute multiple ssh remote commands tom221 Linux - Newbie 2 01-28-2005 02:00 PM
executing multiple commands by ssh jpan Linux - General 1 10-22-2004 03:12 PM

All times are GMT -5. The time now is 06:19 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration