LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Input redirecting (https://www.linuxquestions.org/questions/linux-newbie-8/input-redirecting-429598/)

Thomas Ene 03-29-2006 06:32 AM

Input redirecting
 
Hi.
I am trying to do a script that will be able to read the input from a file or the output of a script (best).

For example: if I want to specify a password to a scp command
I have done a first script simmilar to this:

sleep_pass
---------------
sleep 3
echo "password"

and piped this script script to the scp:
./sleep_pass | scp a.txt user@host:/path/
( the sleep 3 command was for waiting the scp to get a password prompt
I am not sure however that this is the way to do it :) )

unfortunatley it's not working.
Another idea that I had was to writing to the tty: something like:
echo "pass" > /dev/pts/5... (but is not working either)

Do you have any ideas about this?
Can this be done... ( I am sure it can be done.. I am not sure that it's just as simple)

Thank you very much

acid_kewpie 03-29-2006 07:59 AM

you've not really described how you want this entire solution to work, but i would guess you'd want to look towards expect for this. expect is specifically designed for automating interaction with remote devices and other application requiring user responses. you can also use the autoexpect program to basically watch what you do and remember how to do it again.

Jeiku 03-29-2006 09:28 PM

you can't do this. If you want it to work like that you will need to setup ~/.ssh/authorized_hosts and add the keyfile of the user connecting to that file. You can then specify the private file to scp and it will not ask for a password.

Jeiku 03-29-2006 09:30 PM

PS.
Sorry that was not very clear, see:
http://www.puddingonline.com/~dave/p...s-HOWTO-4.html

http://www.eos.ncsu.edu/remoteaccess/man/scp.html

you can then specify the -i option to scp

acid_kewpie 03-30-2006 12:16 AM

to the question you actually asked the answer is "expect". to the question you should have asked if the task is solely to automate static scp commands, the answer is shared keys under ssh. There would be no need to use specific -i flags if your generic ssh security is configured to allow rsa / dsa access. there's a good article in our wiki about how to configure this.


All times are GMT -5. The time now is 02:34 AM.