CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
How do I pass the return(or enter) key into a command line?

 



swabbies
Novice

May 12, 2003, 12:06 PM

Post #1 of 3 (380 views)
How do I pass the return(or enter) key into a command line? Can't Post

hello,

I am trying to write a script that passes input to a win32 cmd line.

open(CDB,"|cdb.exe frsstress.exe /cfgfile stress.xml") or die "Unable to start ntsd...";

sleep(30);
print "g"; ###what I want to do here is pass the letter "g" and then enter(return)
sleep(15);
print "g"; ###what I want to do here is pass the letter "g" and then enter(return)
sleep(60);
print "q";


Any input would be greatly appreciated.

thanks,

Ben


davorg
Thaumaturge / Moderator

May 13, 2003, 1:16 AM

Post #2 of 3 (375 views)
Re: [swabbies] How do I pass the return(or enter) key into a command line? [In reply to] Can't Post

It's not clear what you're asking, but I assume that you want to pass these values into the command line pipe that you've opened up.

In that case you'll need something like this:


Code
sleep(30); 
print CDB "g\n";
sleep(15);
print CDB "g\n";
sleep(60);
print CDB "q\n";


But you may have more success using something like Expect.pm.

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks


swabbies
Novice

May 13, 2003, 7:23 AM

Post #3 of 3 (370 views)
Re: [swabbies] How do I pass the return(or enter) key into a command line? [In reply to] Can't Post

thanks for the reply, I should have been clear with my intent. The code in the previous post works when there is a cmd line present. The strange feature of the .exe that I use is that the letter "q" acts as a break, so the .exe is running and there is no cmd line to enter the lettter "q" into. Is there a way to pass it to the .exe without having a cmd line to enter it onto?

The original question wasn't clear, but I am looking for a way to have the return or enter key passed into the cmd line. so I could pass it the lettter "g" and then pass the return or enter key to execute the letter
"g".

Thanks,

Ben

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives