in reply to open2 or 3 run command using pty
Before trying to run an interactive session, consider trying to run the session in batch mode:
my $tempfile= '/tmp/sql_output'; my $sql = "select * from users"; open (COMMAND, "| /opt/sql >$tempfile" ) || die $!; print (COMMAND "connect credentials") print (COMMAND "$sql\n"); open my $results, '<', $tempfile or die "Couldn't read '$tempfile': $!"; while( <$results> ) { print $_; };
Trying to run a program interactively usually brings lots of problems when the program is buffering its output. So I prefer to stuff all commands into one string, send that string to the program, and then read the output from a file.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: open2 or 3 run command using pty
by klimenkoandrey (Initiate) on Jul 21, 2014 at 09:34 UTC | |
by Corion (Patriarch) on Jul 21, 2014 at 09:38 UTC | |
by klimenkoandrey (Initiate) on Jul 21, 2014 at 09:40 UTC | |
|
Re^2: open2 or 3 run command using pty
by klimenkoandrey (Initiate) on Jul 21, 2014 at 10:03 UTC | |
by Corion (Patriarch) on Jul 21, 2014 at 10:08 UTC |