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

Notices

Reply
 
Search this Thread
Old 04-03-2006, 05:02 PM   #1
Singist
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*\>\// ) {

$count++;

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

COLOR\=\"RED\"\>$line</FONT\></A></TD></TR>";


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, 06:25 PM   #2
RHELL
Member
 
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, 09:14 AM   #3
ARC1450
Member
 
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.
 
  


Reply


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 03:26 AM
LXer: Execute commands simultaneously on multiple servers LXer Syndicated Linux News 0 02-20-2006 11:31 AM
LXer: Execute Commands on Multiple Linux or UNIX Servers LXer Syndicated Linux News 0 12-27-2005 06:46 PM
execute multiple ssh remote commands tom221 Linux - Newbie 2 01-28-2005 01:00 PM
executing multiple commands by ssh jpan Linux - General 1 10-22-2004 02:12 PM


All times are GMT -5. The time now is 08:59 PM.

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