T
tpurl
Hi, I've searched for hours on how to do this to no avail. Any help I
can get would be greatly appreciated!
I would like to interact with a console app that expects you to log in,
send it commands, and then log out. A typical session might look like
this:
$ ./myapp -u user -p pass
myapp> setval 10
myapp> getval
(prints 10)
myapp> exit
$
I've heard that you can do something like this with the expect module,
but I would rather not have to install it on the machine with which I'm
working. I tried something like this:
my $myapp = "/usr/bin/myapp -u user -p pass";
open(MYAPP, "|$myapp") or die "Cannot execute $myapp: $!";
print MYAPP "setval 10";
print MYAPP "getval";
print MYAPP "exit";
my @lines = <MYAPP>; # read the value returned from the getval command
close(MYAPP);
However, this just blows up in my face. Does anyone point me in the
right direction on this one?
Thanks again!
Tom Purl
can get would be greatly appreciated!
I would like to interact with a console app that expects you to log in,
send it commands, and then log out. A typical session might look like
this:
$ ./myapp -u user -p pass
myapp> setval 10
myapp> getval
(prints 10)
myapp> exit
$
I've heard that you can do something like this with the expect module,
but I would rather not have to install it on the machine with which I'm
working. I tried something like this:
my $myapp = "/usr/bin/myapp -u user -p pass";
open(MYAPP, "|$myapp") or die "Cannot execute $myapp: $!";
print MYAPP "setval 10";
print MYAPP "getval";
print MYAPP "exit";
my @lines = <MYAPP>; # read the value returned from the getval command
close(MYAPP);
However, this just blows up in my face. Does anyone point me in the
right direction on this one?
Thanks again!
Tom Purl