[Novalug] Perl calling multiple shell commands - wrapping my head around it.

Jon LaBadie novalugml@jgcomp.com
Wed Feb 1 13:50:28 EST 2012


On Wed, Feb 01, 2012 at 12:59:23PM -0500, Miles D. Oliver wrote:
> I just turned 50.. Can anybody tell me when 'senior moments' start???
> 
> This is working and I can pass multiple commands to the bash shell and can
> connect to the DB fine but it looks like I have to do some additional
> reading to understand how to save the output of the shell command into
> something I can work with, say to get into an array
> 
> @array = `shell command` isn't working in this context because I think its
> a fork of a different process.
> 
> open SHELL, "|/bin/bash" or die "Couldn't open bash shell $!";
> print SHELL $conn;
> print SHELL $cmd1;
> foreach $line(@array)  (want array to be output of $cmd1;
> ....
> 
> Any thoughts?

Created a named pipe (FIFO) with mknod
Redirect $cmd1 to write to the fifo.
Open the fifo for reading and input the results into @array.
Remove the fifo.

-- 
Jon H. LaBadie                  novalugml@jgcomp.com
 11226 South Shore Rd		(703) 787-0688 (H)
 Reston, VA  20190		(609) 477-8330 (C)



More information about the Novalug mailing list