ksh script with Interactive ssh on remote server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ksh script with Interactive ssh on remote server
# 1  
Old 09-08-2011
ksh script with Interactive ssh on remote server

HI Unix Gurus,

I an stuck in an interesting issue, where I am trying to execute a script on remote server after ssh.
The script on remote server is interactive,. Whenever it is called it hangs where it expects input from terminal and I have to terminate it.

I have searched through fourm and found -t -t is one option to use, but its not working in script, though it works from the shell prompt for execution of single command.

Can any one help me with this please.

Below are the brief contents of the KSH Script.

Code:
#!/bin/ksh
ip=192.168.113.14
hst=rhel_server
 
flg=0
 
if [ ${flg} -eq 0 ]
then
ssh -o IdentityFile=/root/.ssh/id_dsa -t -t root@${ip} << EOF
ksh /remote_script/server_install_soft.ksh ## Interactive Script
rm /tmp/log/old_log.log
EOF
fi
exit


Last edited by Scott; 09-08-2011 at 08:06 AM.. Reason: Please use code tags
# 2  
Old 09-08-2011
What does your script /remote_script/server_install_soft.ksh ?
You may need to automate your script to avoid any interactive input.
When you are running ksh, it is waiting for input in that session, not in your ssh session.
# 3  
Old 09-13-2011
HI PSShah,

My requirement is to have /remote_script/server_install_soft.ksh script intractive.
This script takes inputs from screen like select option 1,2 3 or press enter to continue etc.

As you said its waiting for input in that session and not in my session,
I need to know is it possible to supply input from my current shell.

Thanks,
Jivan
# 4  
Old 09-13-2011
Try like this:

Code:
#!/bin/ksh
ip=192.168.113.14
hst=rhel_server
 
flg=0
 
if [ ${flg} -eq 0 ]
then
    ssh -o IdentityFile=/root/.ssh/id_dsa -t -t root@${ip} '
        ksh /remote_script/server_install_soft.ksh ## Interactive Script
        rm /tmp/log/old_log.log '
fi
exit

# 5  
Old 09-16-2011
Hi Chubler_XL,

The Result is same .. the Script hangs,
Any other options is available
# 6  
Old 09-27-2011
Hi All Gurus,

I am still unable to solve this problem and expert advise will really help.

Thanks.
# 7  
Old 09-27-2011
Code:
[apple@bt ~/aen]cat run
#!/bin/bash
echo "Please enter an integer value : "
read var
echo "Entered value is $var"
 
[apple@bt ~/aen]ssh apple@192.168.1.3 "echo 123 | /home2/apple/aen/run"
Please enter an integer value :
Entered value is 123

Something like this?

--ahamed
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

Script connect to remote server, not find files and exit only from remote server, but not from scrip

I have a script, which connecting to remote server and first checks, if the files are there by timestamp. If not I want the script exit without error. Below is a code TARFILE=${NAME}.tar TARGZFILE=${NAME}.tar.gz ssh ${DESTSERVNAME} 'cd /export/home/iciprod/download/let/monthly;... (3 Replies)
Discussion started by: digioleg54
3 Replies

4. Ubuntu

Run a script at remote server without ssh password

Hello, What I want to do is to run a file on remote server by running a script at localhost but script should not ask ssh password of my remote server when script is executed. Scenario1: To copy files from server2 to data server:$ scp -r root@server2_ip:/var/www/html/*.* /var/ When I enter... (6 Replies)
Discussion started by: baris35
6 Replies

5. UNIX for Dummies Questions & Answers

Executing ksh script to remote server want output on same window

I'm having a brain freeze moment. I've created a ksh script in AIX that ssh's to a remote server, executes some commands, and then logs out. All of this is sent to a file. I then have the script cat the file so i can see the output. Even though the cat command is outside of the remote session part;... (5 Replies)
Discussion started by: seekryts15
5 Replies

6. Shell Programming and Scripting

Script to ssh to remote server

Hi All, I need to prepare a script. Description: Currently i am in server "x(ubuntu os)", here i need to develop a script to ssh to another server "y(ubuntu os)", i have password less authentication to "y". i have done the below #!/bin/bash #ssh to the server "y" and confirming i am... (2 Replies)
Discussion started by: kumar85shiv
2 Replies

7. Shell Programming and Scripting

manage an interactive script on a remote host

OS~AIX 6.1 I'm running an interactive shell script i.e.,waits for a user response a few times while executing, after doing ssh to a AIX server. I'm just wondering what options I have if the ssh connection to the server is lost while executing the script, do I have to run the script again, which in... (2 Replies)
Discussion started by: mbak
2 Replies

8. Shell Programming and Scripting

Running a function on a remote server via SSH in a script

I'm working on a script (mostly for practice) to simplify a task I have to do every now and then. I have a cluster with 6 servers on it, each server has a directory with a set of files called *.pid and *.mpid. Each file contains the pid of a process that may or may not be running on that server.... (3 Replies)
Discussion started by: DeCoTwc
3 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

automatic ssh into remote server using ksh

I still have to enter the password when I want to auto login w/o having to do any command line entry. This code works but I don't want to have to enter the password at the command line. After manning ssh I still am not sure what settings I need to change. Please help. Thanks! <<<output>>>... (4 Replies)
Discussion started by: tekline
4 Replies
Login or Register to Ask a Question