Please note that LinuxExchange will be shutting down on December 31st, 2016. Visit this thread for additional information and to provide feedback.

I need to use ssh to send command to different computers to run programs. Can I define a variable of Directory and program in front of this shell script? Then, I do not need to write them every time?

host_list=("c15-0330-10.ad.mtu.edu" "c15-0330-11.ad.mtu.edu" "c15-0330-12.ad.mtu.edu") # I have multiple programs # program=c("L_1","L_2","L_3") ssh -f "${host_list[0]}" 'set Directory="/home/campus27/zwang10/Desktop/AWRR/program/power/vmodel_1/nprot/K_10"; cd $Directory && nohup Rscript L_1.R> L_1_sh.txt;echo "The job L_1 is finished" |mutt "zwang10@mtu.edu" -s "The job L_1 is finished"'; ssh -f "${host_list[1]}" 'set Directory="/home/campus27/zwang10/Desktop/AWRR/program/power/vmodel_1/nprot/K_10"; cd $Directory && nohup Rscript L_2.R> L_2_sh.txt;echo "The job L_2 is finished" |mutt "zwang10@mtu.edu" -s "The job L_2 is finished"'; ssh -f "${host_list[2]}" 'set Directory="/home/campus27/zwang10/Desktop/AWRR/program/power/vmodel_1/nprot/K_10"; cd $Directory && nohup Rscript L_3.R> L_3_sh.txt;echo "The job L_3 is finished" |mutt "zwang10@mtu.edu" -s "The job L_3 is finished"';

asked 23 Apr '15, 17:12

zwang10's gravatar image

zwang10
111
accept rate: 0%

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×8
×5
×5

Asked: 23 Apr '15, 17:12

Seen: 6,308 times

Last updated: 23 Apr '15, 17:12

powered by OSQA