Execute script located on a remote machine


 
Thread Tools Search this Thread
Special Forums IP Networking Execute script located on a remote machine
# 22  
Old 07-06-2012
Can you clarify how you connect through PuTTY though? Do you use a saved session with additional default commands executed on ServerA on login?

---------- Post updated at 04:22 PM ---------- Previous update was at 12:22 PM ----------

Also, can you confirm if you can use key-based authentication for either server, and whether you can log into ServerA without passing straight through to ServerB?
# 23  
Old 07-09-2012
Error

Quote:
Originally Posted by spynappels
Can you clarify how you connect through PuTTY though? Do you use a saved session with additional default commands executed on ServerA on login?

---------- Post updated at 04:22 PM ---------- Previous update was at 12:22 PM ----------

Also, can you confirm if you can use key-based authentication for either server, and whether you can log into ServerA without passing straight through to ServerB?
We use putty.exe and feed in the host-name of ServerA. Upon login it propts for the credentials of serverA. As soon as you provide them it automatically takes the same user1 as the login and prompts us for the password for ServerB. So we have to authenticate credentials on both the servers explicitly.

I dont know what are saved sessions. If it is something on ServerA or ServerB then I would need yr help figure it out. If it is something on our windows terminal then I can assure you that there is nothing saved as such.
# 24  
Old 07-09-2012
Ok, that sounds very much like there is a saved session there.Do you not use the PuTTY GUI at all?

I suspect that instead of running
Code:
putty.exe <serverA>

you ran
Code:
plink <serverA> "hostname"

you would get the hostname of serverB returned after being prompted for the password twice, same as when using putty.

If that is the case, you need to get key based authentication enabled/configured to allow any script the chance to work without a human in attendance.
# 25  
Old 07-09-2012
Error

Quote:
Originally Posted by spynappels
Ok, that sounds very much like there is a saved session there.Do you not use the PuTTY GUI at all?

I suspect that instead of running
Code:
putty.exe <serverA>

you ran
Code:
plink <serverA> "hostname"

you would get the hostname of serverB returned after being prompted for the password twice, same as when using putty.

If that is the case, you need to get key based authentication enabled/configured to allow any script the chance to work without a human in attendance.

I never ran this in my life.

Code:
 
putty.exe <serverA>

I use putty GUI only.

I did not get what did you mean when you said to use plink.

See my output below.

Code:
C:\Program Files\PuTTY>plink -v -ssh user1@ServerA hostname

gives me the hostname of serverA and not serverB.

Am i missing something ?
# 26  
Old 07-30-2012
Hi Guys,

I have some good inputs as i made a little progress on this.

Sorry for bieng away for some concerns.

Anyways, below is the progress...

Code:
plink user1@ServerA -m local_script.sh -v
 
id
uid=3800(user1) gid=74(sshd) groups=74(sshd)
pwd
/home/ServerA/user1
cat .profile
echo "Connecting to: serverB"
exec /usr/local/bin/serverB
                exit
ls -ltra /usr/local/bin/serverB
-r-xr-xr-x 1 root root 2406 Feb  8 15:37 /usr/local/bin/serverBplink user1@ServerA -m local_script.sh -v

So, now we know how is it switching from ServerA to ServerB automatically.

However, this switch happens when I use putty GUI and does not happen when using plink.

Regardless, I wish to execute a script on ServerB. Can you now help me what needs to be done on ServerA or ServerB to get my teask accomplished ?

Last edited by mohtashims; 07-30-2012 at 09:19 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can I execute local script on remote machine and include arguments?

I have a script in local server cd /home/dell/work/BOP/testdir ./processchk po (here processchk is a script & po is passed as an argument) Now I want to execute this script from remote server ssh $username@$hostname "cd /home/dell/work/BOP/testdir; ./processchk po" But Its getting error... (9 Replies)
Discussion started by: manohar2013
9 Replies

2. Shell Programming and Scripting

Execute shell script on remote machine

I want to execute a shell script(set of commands) on remote machine and that script takes input from text file(local machine). Please refer below: ssh user@hostname 'bash -s'< ./test.sh file.txt But i got the error file.txt doesn't exist. Can anyone help me on this. Content of test.sh: ... (2 Replies)
Discussion started by: manishtri88
2 Replies

3. UNIX for Dummies Questions & Answers

Execute shell script in remote machine

Hi All, We have 2 servers A and B. B is having a sctipt called b.sh in path /home/dev/scripts. Now my requirement is i want to execute b.sh from server A. Kindly help me. (3 Replies)
Discussion started by: Girish19
3 Replies

4. Shell Programming and Scripting

How to execute the same script on another machine

Recently, I need to generate a lot of files from a few master files. In fact, if I relogin to the server machine, my operating would be much faster. My question is this: Can I write a script in which the current path can be automatically saved and relogin to the server to execute my command in the... (0 Replies)
Discussion started by: jiao
0 Replies

5. Shell Programming and Scripting

To execute the same script in another machine

We have a few machines which share the same directory. How can I execute the same script under that directory in different machine while I am using mine? (1 Reply)
Discussion started by: jiao
1 Replies

6. Shell Programming and Scripting

unix shell script which inserts some records into a file located in remote servers...

All, I need to write an unix shell script which inserts some records into a file located in remote servers. * Get the input from the user and insert according the first row. It should be in ascending order. 123451,XA,ABA 123452,XB,ABB 123453,XC,ABC 123455,XE,ABE 123456,XF,ABF 123458,XG,ABG... (2 Replies)
Discussion started by: techychap
2 Replies

7. Shell Programming and Scripting

Change user on remote machine and execute script!

Hi, I need to login into remote server and execute a shell script over there. As of now i am making use of ssh command ssh primUser@135.254.242.2 sh /poll.sh I am logging in as primUser but unless i change the user to root the script execution on the remote machine is not possible. ... (5 Replies)
Discussion started by: goutham4u
5 Replies

8. Shell Programming and Scripting

How to execute a script hosted on a machine from a different machine

Hi everyone I intend to trigger a script from one machine say mc1 that actually excutes on different machine say mc2 and redirect the logs to that machine mc2. I tried to use nohup <nfs location of machine >/script.sh > <nfs location of machine >/script.log 2>&1 & nfs location of... (2 Replies)
Discussion started by: harneetmakol
2 Replies

9. Shell Programming and Scripting

Execute command from terminal on remote machine

Hi All, I want to execute some commands on unix machine from the mac machne. I have two options for doing so, I am confused which is the best way of doing. Here are two options. Requirement: Execute command on the remote server machine. Commands to be executed itself contain arguments to be... (0 Replies)
Discussion started by: Ranu
0 Replies

10. Shell Programming and Scripting

how to execute a script on remote machine

hi unix guru's i am new to unix shell programming. i found a trouble in executing a script(bali.ksh) which is available on serverA with username xyza, this script contains sqlplus command to retrive the data from the database available on other serverC. Now i need to run the above script... (4 Replies)
Discussion started by: balireddy_77
4 Replies
Login or Register to Ask a Question