LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-22-2004, 01:54 PM   #1
jpan
Member
 
Registered: Aug 2004
Distribution: Debian Libranet
Posts: 69

Rep: Reputation: 15
executing multiple commands by ssh


Hi, i'm writing a bash script so that i can
login into a machine by ssh AND run multiple commands on that
machine....anybody knows that??

what i know now is to run a single command like:
$ssh root@ip_address command1

but how to run multiple commands??
 
Old 10-22-2004, 02:12 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Is this what you want:

$ ssh root@your.ip "ls -l / | grep tmp ; echo 'A rather dumb example'"
drwxrwxrwt 3 root root 12288 Oct 22 21:05 tmp
A rather dumb example


It's not a very usable example, but it shows that it is possible to use a command (ls -l) pipe it to another program (grep) and prints a message (echo).

Hope this helps.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
execute multiple ssh remote commands tom221 Linux - Newbie 2 01-28-2005 01:00 PM
executing shell commands in c++ true_atlantis Programming 2 10-01-2004 04:53 PM
remote ssh commands on multiple hosts evilchild Linux - Software 6 08-12-2004 10:48 PM
Executing commands in Konsole... meteotrade Linux - General 5 10-20-2003 06:34 PM
Executing commands on startup viciousfish Linux - General 5 06-28-2002 02:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:47 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration