LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-10-2005, 01:41 PM   #1
downbound010
LQ Newbie
 
Registered: Dec 2005
Posts: 10

Rep: Reputation: 0
Nested Bash Script


I'm trying to write a nested bash script that executes a bash command on another server using ssh.

Basically I'm doing this.

#/usr/bin/ssh -l user command\ logout

Now that works just fine until I start getting more advanced into bash scripting.

what I would LIKE to run on that server is

for i in `ls folder`; do cat folder/$i && echo '----'; done;

basically outputs the contents of everthing in a folder seperated by ----

if I try to run it as I normally would above, it tries to run the bash script locally. I've tried just about everything I can think of as far as using quotes to block portions off using backticks to seperate the ;'s and `'s out etc. If anyone knows how to do this, I could use some direction.

Thanks
 
Old 12-10-2005, 02:37 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
Hi,

You need some additional quoting:

ssh -l user system 'for i in `ls folder`; do cat folder/$i && echo "----"; done'

Everything between the single quotes is send to the remote host and is not first expanded locally.

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help for bash script moodupani Programming 6 09-09-2005 03:59 AM
Bash Script cynicall Linux - Newbie 4 10-12-2004 09:19 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
bash script - incrementing a filename in a script tslinux Programming 10 08-05-2003 11:58 PM
bash script prob: how can i tell the script that a 'dd' has finished? Frustin Linux - General 2 04-02-2003 05:34 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:24 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