Shell script that SSH's into another machine, runs another script, 2nd script asks for user input -
Shell script that SSH's into another machine, runs another script, 2nd script asks for user input -
ssh -t -t me@myothermachine.ca<<eof cd ../../path/to/script/directory/ sh copyfiles.sh cd ../../copied/directory sh renamer.sh exit eof
hi guys,
the script above i'm working with. copyfiles.sh has 'read' asking year , month of files i'd copy. files copying has year , month in title looks @ title of file , finds files year , month user enters. it's easier have @ code see it's doing actually. here is.
#get year , month user echo "please come in year" read year echo "please come in month" read month files=`find . -name "*$year*$month*.txt"` file in $files; cp $file /the/copy/to/directory done
the issue come in "2014" when asks, hangs.
it logs other machine, shows the middle 5 lines of code initial script, starts reading them commands. cd's properly, gets sh copyfiles.sh script, asks year, come in year, , hangs.
is user input shell script not doable?
you can't that. if have source copyfiles.sh
, should modify can pass required input arguments copyfiles.sh
. then, ssh session can execute you, e.g.
ssh -t -t me@myothermachine.ca<<eof cd ../../path/to/script/directory/ sh copyfiles.sh --year 2014 --month june cd ../../copied/directory sh renamer.sh exit eof
shell ssh nested
Comments
Post a Comment