Switching server in UNIX via shell script (SSH )


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Switching server in UNIX via shell script (SSH )
# 1  
Old 06-29-2015
Switching server in UNIX via shell script (SSH )

Requirement: I am writing a shell script which take some file from say Server1 and I have to execute some command on Server2 then I have to manipulate the data and based on that I have to produce report.
Problem:I can schedule the shell script on only one server (Server1 or Server2) So, In the shell script itself I have to switch the server . If I will switch the server then it will prompt for the password. I don't want that as it will be scheduled(No one will be there to enter the password)

Please suggest me the way to hardcode the password or switch the server without password.

(I have no right to install anything on server )
# 2  
Old 06-29-2015
Welcome raks2301,

Thanks for an interesting question Smilie

If you plan to switch the server within your script, how would you plan to do it? Would it be rsh/resh/remsh, ssh or something else? These can be set up to act without a password for scheduled work without the need to install anything else.


It would be good to know the OS of each server, so the output of uname -a would help there.


I'm assuming that you would you need to pass data between the servers as well as generate a report. Can you elaborate how to are set up, how you drive your schedule and what you use to move/copy data. There are various options we can explore.


What have you tried so far, and where do you get stuck?

Please post code, files, input & output/errors in CODE tags as it makes them easier to read and preserves multiple spaces for indenting and fixed width data.


Thanks, in advance,
Robin
This User Gave Thanks to rbatte1 For This Post:
# 3  
Old 06-29-2015
Thanks for the reply !!
Here are the answers for the questions
I am using ksh...
uname is AIX

ssh and scp commands works.
I tried both the commands to copy the file but everytime it asks for the password.
I tried the passphrase method , everything was executed successfully but when switching It asks for password.

I am reading a file(created daily ) from on server and based on that I am extracting some strings ... Then I have to read file from other server also and extract string from there also ... Then I have to send email via unix (scheduled email) , For this I want my code to be scheduled in such a way that autogenetrated email should be sent on daily basis after reading file from both of the server.
# 4  
Old 06-29-2015
Searching a bit our forum you would have found e.g.
Can't solve a simple SSH/scp issue.. Please help.

look how to configure for passwordless ...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to have local shell variables in a ksh script seen on remove server in SSH block?

I have googled this and found many solutions, but none of them are working for me. I am in a korn shell, most others reference bsh, maybe that is the issue? Anyway, all I am trying to do is use a variable I have declared in my main script in a remote shell I am running through ssh. So I have a... (8 Replies)
Discussion started by: DJR
8 Replies

2. UNIX for Beginners Questions & Answers

How to execute setDomainEnv.sh in wblogic via ssh on remote server in shell script?

How to execute setDomainEnv.sh in wblogic via ssh on remote server in shell script we execute setDomainEnv.sh manually as . ./setDomainEnv.sh from its location ie /opt/SP/users/domian/bin" My approach is not working. Please advise. #!/bin/bash set -x base="/opt/SP/users/d1/bin"... (5 Replies)
Discussion started by: abhaydas
5 Replies

3. Shell Programming and Scripting

FTP from windows to unix server using unix shell script

Hi, Is it possible to ftp a huge zip file from windows to unix server using unix shell scripting? If so what command i need to use. thanks in advance. (1 Reply)
Discussion started by: Shri123
1 Replies

4. UNIX for Dummies Questions & Answers

ssh command to execute shell script in another server

ssh -q <hostname> /opt/tcs/satish/tst.ksh ssh -q <anotherserver> /opt/tcs/satish/tst.ksh tst.ksh has "nohup <command> & " when i execute below script , its throwing error as nohup can not be found ssh -q <anotherserver> /opt/tcs/satish/tst.ksh > log & can someone let me... (5 Replies)
Discussion started by: only4satish
5 Replies

5. Shell Programming and Scripting

problem switching to directory using shell script

Hi, I have an issue with switching to other directory through shell script. I have used cd /Music" but that doesn't help me. Then I have also tried using alias proj 'Music' alias then I get the error permission denied but i set the chmod 777 Music. I am using cShell for my... (3 Replies)
Discussion started by: baluk
3 Replies

6. Shell Programming and Scripting

Run shell script on another server using ssh

Hi, I have 2 servers and i installed ssh2 on both boxes .. so they they can communicate with each other with our password auth .. now i want to write a scrip on box 1 for running commands and getting out put from the second box can some one help me out Thank you in advance (1 Reply)
Discussion started by: anwesh
1 Replies

7. UNIX for Dummies Questions & Answers

Switching user inside a shell script

Dear All, I want to switch a user inside a shell script.My current user say x and user y to whom i want to switch both have login on the same server,the one on which i want to execute my script on. "I want to do something like this su - y Password should be provided in the script itself.And... (6 Replies)
Discussion started by: navjotmannan
6 Replies

8. Shell Programming and Scripting

Connecting to multiple unix server from unix server using shell script

Hi Gurus, I'm a unix newbie and I would like to connect to multiple unix servers from unix server using shell script i.e from server a to server b,c,d etc. I want to copy the files from unix server a to server b, c, d. I can access staright using ssh without the need to have password and user... (5 Replies)
Discussion started by: sexyTrojan
5 Replies

9. Shell Programming and Scripting

shell script for how to connect to a remote server by using ssh

i want to connect to a remote server through ssh. i have to also provide password within that script. after connecting to the remote server i want to do some operations like grep,cd etc can u pls help me to wite a script. Thanks (1 Reply)
Discussion started by: millan
1 Replies

10. Shell Programming and Scripting

switching to another user in shell script...

Hi, I have a shell script in which I need to switch to another user and execute some commands and then come back to the original user. To make it more clear - I have to log in as user root then 'su' to jag - execute a script called backup.sh and then logout and come back to root again.. ... (1 Reply)
Discussion started by: bjagadeesh
1 Replies
Login or Register to Ask a Question