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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

perl - piping commands to another program - any help please

Status
Not open for further replies.

m4trix

Vendor
Jul 31, 2002
84
CA
Hi, First off I want to mention that I am using the WINNT OS (XP actually - but same thing)

Here's what I want to be able to do. I use a program every day. It runs in dos. It is fairly simple, and I navigate menus using the keyboard, and input information, again, using the keyboard. What I was wondering, is if there is any way that I can use a perl program to do this for me. Essentially, What I want to do is go into a perl program to enter my data. The perl program opens up this other program, navigates to the proper spot, enters the information, AND writes the information to a text file as well. The second part is super easy, I just can't figure out how to get the script to work with this other program.
I figure I have to do some kind of piping, but I don't know much about that at all.
any help would be appreciated,
thanks,
-Mike
 
Not knowing exactly what it is your DOS program is doing, mybe youy could explain a little more. As far as taking input from the keyboard to the command prompt, perl uses STDIN like such:

print "Here is where you will input info or argument: ";
chomp ($input = <STDIN>);
print &quot;$input\n&quot;;


HTH- Stiddy
 
What I think you want to do is open a pipe to write to the program. Here's an example:

open(P, &quot;| time&quot;) or die &quot;Can't open pipe: $!\n&quot;;
print P &quot;10:55\n&quot;;
close(P);
 
hmmm. Stiddy, I know that much (the <STDIN> thing). As for what the program is doing.. Umm.. well, see I don't know any of the inner workings of it. All I know is that I open it, get to an intro screen where I press any key. That takes me to a login screenw where I type my login & password. Once inside, there is a large menu that is lettered. when I press A, it goes to the first item on the menu for example, and pressing enter enters it, for example.

To raider2001, I've tried that, but I don't know what to print to the program. I don't know much about your example specifically, but if you were to change
print P &quot;10:55\n&quot;;
to
print P &quot;hello\n&quot;;
That wouldn't work would it. Because I figure the Time program doesn't know what to do when it recieves the string &quot;hello\n&quot; I could be wrong. But if not, then that's an example of what I'm stuck with. I don't know what to send to the program to make it do what I want. I've tried sending all the keystrokes I use to do what I want, and had no success.
 
Mike,

Look at thread219-332727 it sounds like what you looking for.

In it, justice41 suggests using the Expect module.

See if that helps.

tgus

____________________________
Families can be together forever...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top