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.

#!/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

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.

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

Try like this:

#!/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

Hi Chubler_XL,

The Result is same .. the Script hangs,
Any other options is available

Hi All Gurus,

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

Thanks.

[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

try this

ssh -o IdentityFile=/root/.ssh/id_dsa root@${ip} 'ksh /remote_script/server_install_soft.ksh;rm /tmp/log/old_log.log'

Nope, this I have tried but it does not work,

I have to execute the script /remote_script/server_install_soft.ksh :wall:on remote server from my current shell. As explained in detail in the beginning of the thread.

Thanks

what is the output after this?

# ksh -x yourscript

Dear friend,ygemici
Could you please explain why you need "-x" (execution output) here?
The question is how to execute an interactive script from server A on server B.
As far as I know The "-x" is irrelevant here. Request you to go through the question once again and correct me if I am wrong.

The question is still open for all and not yet resolved.

The alternate I am using is to send feedback why ssh from server B to server A and execute scripts there, unfortunately its very vary complex :confused::frowning:

I'm trying to figure out the cause of the hangup.
debugging,everytime gives an idea.
now can you write the contents of script?

# cat server_install_soft.ksh

Post #7 is about as near as you are going to get. It provides typeahead to the interactive program. This usually works better with the "-n" switch to the remote Shell program. The remote shell approach is best done with a custom script on the remote computer.

If you want to work interactively with a remote computer you need to login properly, do your typing, and then logout. There may workarounds for repetitive tasks but don't bet on it.

I'm not still clear what you are actually trying to do. All we have to work on is a solution which does not work. We need to see the problem.