ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
The run program part starts the app fine. But the next menu option (16) doesn't get selected.
This is running inside a k shell on AIX if that makes any difference. Any ideas on how to get this to work? Sorry if this is an easy question, I'm still new to perl.
I looked through the docs, and I'm still not finding it. I tried to open the program as a process with a leading pipe and then printing to the process, but all subsequent writes have the initial command sent. open (UPIPE, "|run unix") does open the program though. Here is where I left off.
foreach $endpipe (@endpipe) {
open (UPIPE, "|$endpipe") || die "cant open program: $!";
close UPIPE;
}
_______________________________
I've tried numerous different combinations. Any idea's on what I need to try? I figured opening a program and selecting a few menu options (mimicking keystrokes) would be fairly easy. Man, was I wrong.
#!/usr/local/bin/perl -w
# Set the program to run
$progName = "run unix";
# Set the things to pipe to the program
@args = ("16", "2", "1", "y", "q", "y", "\r");
# If the program expects "enter" after the commands, you'll need this instead.
# @args = ("16\n", "2\n", "1\n", "y\n", "q\n", "y\n", "\r");
# Open a file handle to the program
open(UPIPE, "|$progName") or die("Can't open $progName: $!");
# Select UPIPE as the handle we want to print to
select(UPIPE);
# Pass in the arguments
foreach (@args) {
# Since we have UPIPE as the default output hande, and print
# operates on $_ in the absence of parameters, just print();
print;
}
close(UPIPE);
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.