Operating Systems > Linux and UNIX

command output to command input?

(1/4) > >>

Stryker:
Anyone know how I can get the output of one command to go to the input of another. For instance:
echo y | format /U c:
(not for that purpose though)
I want to be able to make a script that can send the output of an echo script to an ssh command so that I can connect to my server and execute commands as a different user. so in the format above:
./passandcmd | ssh [email protected]
would send the ouput of passandcmd to the input of ssh. Any suggestions?

Master of Reality:
you want passandcmd to be an argument or what ssh will send to the remote computer after connected?
I'm assuming passandcmd is short for password and command so you want it to input the password then the command after it connects.
Wouldnt that mean the password would be in plain text???

Stryker:
it wouldn't send the password over a connection, just to that program, which then encryptes it and sends it over the web to the server. that was just an example though. perhaps a bad one. how about this:
ls | sort
so that it will sort the output of the ls command. I just want to know the format of sending the output of one command to the input of another. ls > ./savefile will save the output, but not do anything with it, what would i have to send it to a command instead of a file?

voidmain:
Are client and server both UNIX/Linux?  If so this is really easy although there are even easier ways using SSH than what you are describing. Can you give a detailed description of what you want to accomplish? And you can set up SSH so it does not require a password using "ssh-keygen" (man ssh-keygen), and the userIDs do not have to match.

Stryker:
All I want to accomplish is the knowledge of how to send the output of command A to the input of command B. I dont have any specific goal in mind anymore, I just want to learn something new. And this is 1 thing I know how to do in windows but not linux. I'm not so sure how I could get really detailed about it. lets say I make a program that records all the input it gets, and once it stops recieving input for more than 2 seconds it closes. how would I send 'ls' to that program?

Navigation

[0] Message Index

[#] Next page

Go to full version