System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

How to read INPUT from console for the remote shell !!

 
biswal
Occasional Contributor

How to read INPUT from console for the remote shell !!

Hi

 

  My Requirement is

    If any file in directory1 exists in directory2 on the remote machine , then prompt the user for INPUT (for each existing file). Based on the user's INPUT , perform certain action on that file. Please note that the number of files and file names are not fixed.

 

I tried to use "read" for reading user INPUT, but it does not wait for user's INPUT when used in remote shell. I do not know why it is so?

Is there any way to read the user's  INPUT from the console for the remote shell?

 

Simplified Program(Why read is not waiting for user's INPUT when executed in remote shell)

#!/usr/bin/ksh
       cat <<!EOF! | remsh host1 /usr/bin/ksh -
#!/usr/bin/ksh

echo "Enter A character : \c"
read x
echo $x
!EOF!

 

If you run the above program, then it does not wait for user INPUT.

 

But My requirement is "To wait for user INPUT"

 

Could you please let me know the solution?

 

Thanks,

Biswal

 

2 REPLIES
Mel Burslan
Honored Contributor

Re: How to read INPUT from console for the remote shell !!

It actually is waiting for the input but your line

 

cat <<!EOF! | remsh host1 /usr/bin/ksh -

 

is already feeding the input to this stream I suppose.

 

the best way to script this scenario is to write a script on your local machine, as it will need to run on the remote machine, rcp the file over to the remote machine, then run the script on that machine with a remsh command from your local server. This has a better chance of working, although since it has been like a decade I last used remsh, I don't remember the remote execution behavior. So you will need to test it.

 

And if you don't mind me asking, why aren't you using ssh/scp in this day and age, where security is (or should be) everyone's number one priority ?

________________________________
UNIX because I majored in cryptology...

Re: How to read INPUT from console for the remote shell !!

>It actually is waiting for the input but your line: cat <<!EOF! | remsh host1 /usr/bin/ksh -

>is already feeding the input to this stream I suppose.

 

Right, the input comes form the here doc.

I'm not sure reading from /dev/tty would work?