![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Come and work for me! (UK) | TonyChapman | Linux | 2 | 03-25-2008 02:08 AM |
| How does it work? | nat123 | Linux | 1 | 11-04-2007 10:13 PM |
| Script doesn't work, but commands inside work | cheongww | UNIX for Dummies Questions & Answers | 2 | 11-14-2006 07:52 PM |
| How does tee work | Foxgard | UNIX for Dummies Questions & Answers | 1 | 06-18-2005 12:58 PM |
| Will this work? | Ypnos | Shell Programming and Scripting | 5 | 07-24-2003 10:51 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
ssh, cd to a dir, and and then do some work.
I want to do something like
#!/bin/bash ssh name@computer 'cd /my/dir' and then continue working in this directory. Right now if I execute a script "myscript" containing the above, it just drops me back into the bash shell where I started, whereas I want to be able to do work and stuff on this other computer. I know this command is being execututed because if I change the script to #!/bin/bash ssh name@computer 'echo blah > blah.txt' blah.txt does get created on the remote computer. So the main question is, how do I keep that remote session open rather than reverting back to my original session. I tried ./myscript & but that didn't work. Obviously this is a pretty simple problem, but I figure if I can get this working I learn something that can be applied to solving more powerful scenarios. Thanks for your help in advance! |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
I don't think you can do it like that.
I'm a little rusty but looking at my old scripts I called SSH or SCP everytime I wanted to do one thing. print "scp $USER@$HOSTNAME:$PWD/$5 $4@$server:/tmp/$5" scp $USER@$HOSTNAME:$PWD/$5 $4@$server:/tmp/$5 print "chmod 700 /tmp/$5" ssh -l $4 $server chmod 700 /tmp/$5 print "ssh -l $3 $1 pdadmin -a <user>/tmp/$5" ssh -l $4 $server /usr/bin/pdadmin -a <user>-p $PASSWORD /tmp/$5 print "ssh -l $4 $server rm /tmp/$5" ssh -l $4 $server rm /tmp/$5 I'm not sure the connection will stay open. Maybe try running commands like this but I don't know. ssh -l user myserver chmod 700 /tmp/$5; ls -lrt; date; uptime; Hope this helps. -X |
|||
| Google The UNIX and Linux Forums |