ssh to remote command prompt


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ssh to remote command prompt
# 1  
Old 11-04-2010
ssh to remote command prompt

Hi all,

Scenario - trying to run a batch job on a second machine.

DIR=directory
user=user
server=server

Here is what i have- ssh user@server 'sleep2; cd $DIR; <jobname>'

I have got access to the correct directory, i checked with a pwd command previous.

Problem is the job i am running isnt in this directory but is held on the system somewhere else, but it is required to run from here because of associated files...

Manually if I am on the comand prompt of the second machine i just have to type the <jobname> at the prompt of the $DIR....so how can i get the ssh to do the same from my local machine??

Hope this makes sense and someone can help.

Thanks
Hopper
# 2  
Old 11-04-2010
Meybe you can try
Code:
ssh user@server 'sleep2; cd $DIR; ./<jobname>'

Code:
ssh user@server 'sleep2; cd $DIR; sh <jobname>'

(or whatever shell you use)

Code:
ssh user@server 'sleep2; cd $DIR; nohup <jobname> &'

allso have a look at the -n option of ssh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute ssh command with additional terminal command to any remote user not working script

Hello i am having an issue with bash script and this is the code now=$(cat hosts1.txt | awk '{print $2;}') while read n ;do ssh root@$now 'useradd test1; echo -e "test1\ntest1" | passwd test1 && echo "test1 ALL=(ALL:ALL) ALL" >> /etc/sudoers' When i execute only part with cat, it... (8 Replies)
Discussion started by: tomislav91
8 Replies

2. Shell Programming and Scripting

Execute command on remote host via ssh

How should i make the following code working #!/bin/bash INPUTFILE="test.txt" while read STRING; do IP=`host -t A $STRING | awk '{print $NF}'` HOSTNAME=`ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no $IP "hostname"` echo $HOSTNAME > out.txt done < $INPUTFILE At this moment while... (3 Replies)
Discussion started by: urello
3 Replies

3. Shell Programming and Scripting

Remote command in variable using ssh

Hi, I've an issue in a shell script: I'm opening an ssh connection to a remote server, then I want to store the result of a ls command in a variable, but it doesn't work: the ls is done on the local machine. ssh user@server << EOF ls # works as expected (ls is done remotely) test=`ls` # the... (1 Reply)
Discussion started by: seloum57
1 Replies

4. Shell Programming and Scripting

ssh - running remote command not exiting

Hi, i have a shellscript, where in i need to connect to different server start these three jobs and exit from the server and start the same three jobs on local server. ssh user@remotehost 'bash -s' << EOF ${GETT_HOME}/bin/start1 & sleep 10 ${GETT_HOME}/bin/start2 & sleep 10... (1 Reply)
Discussion started by: swapnabhargav
1 Replies

5. Shell Programming and Scripting

SSH execute remote command (with jump)

Hi all, I am facing the following issue: Host A should execute a remote command (say pwd) on host B2. B2 is not directly reacheable but you have to connect from a to B1, then from B1 you can execute the command ssh user@B2 pwd. B1 and B2 are directly connected: A => B1 => B2 | ... (3 Replies)
Discussion started by: Evan
3 Replies

6. Shell Programming and Scripting

passing arguments in remote ssh command?

i have a bash script on serverA, when i run the script on the server, it runs fine. the way to run the script is like this ./script "option1" Now i am trying to call it from local laptop using ssh command, my command is as the following ssh serverA ~/script "option1" and i got error... (7 Replies)
Discussion started by: fedora
7 Replies

7. Shell Programming and Scripting

script submitted using ssh does not return to command prompt

Gurus, I have written a shell script to backup a database and applications. This is how the script works: 1. As applications user (say applmgr), the main backup script, say backup.sh, is kicked off. 2. backup.sh does ssh to oracle user and kicks off the database backup using nohup and... (1 Reply)
Discussion started by: sunpraveen
1 Replies

8. OS X (Apple)

No command prompt after SSH/SCP

Recently whenever I log out of an SSH session, or copy something using SCP, I get no response from my shell. Running with ssh -v showed no errors when exiting. Normally I could deal with this, but I believe it's causing errors elsewhere when scripts try to download things from external... (0 Replies)
Discussion started by: keymakerOvvvv
0 Replies

9. Shell Programming and Scripting

ssh to remote host and execute command

Hi, could anyone please tell me how to ssh to remote host foo and execute command on it and print the result on local host? Thanks, Paresh (1 Reply)
Discussion started by: masaniparesh
1 Replies

10. UNIX for Dummies Questions & Answers

doubt in ssh command for remote login

Hello sir, Im using ubuntu distro. We all know that ssh is used for password less entry.So, I have the public key and the IP address and the username thats it. Now to login it to the system either I should have password or a private key.Now I have the blacklist of private/public keys. But I dont... (1 Reply)
Discussion started by: nsharath
1 Replies
Login or Register to Ask a Question