Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl in command line

Status
Not open for further replies.

misterius

Programmer
Feb 15, 2009
3
CZ
Hi,
I need execute two commands in command line from running script, but the first is on command line and the second is response to request from server. How can I do it?
My not working example:
open(ORDER, "<some order> -param1 -param2 -user usrname... |")
or die;
#it works, it calls server...
# now the server want the password on command line - how can I give it to him? This do not work:
open(ORDER, "$mypassword");
or die;
close(ORDER);
#This causes nothing -it is waiting until I give him passw. from keyboard and then is used "$mypassword" on new free clear command line(thats wrong), but I need use automatically the variable to answer to server request.

Thanks a lot for help.




 
Thanks a lot, PaulTEG, but I am totally beginner in Perl and Linux too and I do not see the answer in the link you attached. I am confused, there is a lot of text and my english is poor :-( Is there some simple way how to tell to perl, that my order is not new command on bash, but that I want continue with the process I started? It is not necessary to loggin to some server, it should be openning of some other program and then I want give orders to it, to the other opened program. For example if I wanted that my script could run/start vim, joe... write some text(in joe, vim...), save it and leave the program (when I would like use this text editors to save some results from pragram and not write them directly to the file.). I only need redirect the input - not write next order to bash, but to the actuall program (like if I simulate keyboard typing, program know what to type, but do not know how to type to the program - I do not know :)).
Sorry for my noob-ility, but I really need it to solve one big huge nasty problemm :-(
Thanks for all helps and tips (especially for the examples, they helps a lot of). Thanks to all people spending time with reading this mess.
 
Finally I solved it.

It is combination of open and then only print. I tried it before, but it did not work, I do not know, where the mistake was.

open(AAA, "| orders params");
print AAA 'nextorder';
close(AAA);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top