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

Miles D. Oliver miles.d.oliver@gmail.com
Wed Feb 1 08:13:54 EST 2012


Only I cold run into weird stuff like this...

Got a problem I'm trying to solve that I can't seem to wrap my head around
as to the best way to do this.

I have to pull data from multiple sources,  LDAP, Sybase, and others and
use it to create a sequence of commands to push to a proprietary CLI from a
vendor.  The perl script for the LDAP and Sybase sequences in place work
well now.

The nature of the vendors CLI is that I must issue 'starting and ending'
commands as part of the connection to the database.

Here is essentially what I have to pass to the CLI   All CLI commands are
actually a series of exectuables.

'connect, seek, create, show, disconnect'

connect
show 'function' get response, keep as variable
create 'function' based upon variable
create 'function' based on variable... etc.
disconnect

It all has to be done from a single open()  or system() command because the
'connect' and 'disconnect' statements actually start a daemon to pass the
commands to.  It all must be done with a single call, otherwise it won't
work.  the DB does keep track of connections.

All I've been able to come up with is

open DATA (connect;commands;disconnect|" or die "Couldn't execute program:
$!";)
while {
parse out the response;
}
close DATA;

This is all well and good for a single CLI command  I get but if I do it
this way I will have to constantly open and close connections for each
command I have to do and this is highly inefficient.

I'd like to 'connect, keep the connection open for multiple commands and
disconnect.


Any idea how I would accomplish this?  open a session to the CLI from
within PERL and being able to issue multiple 'shell commands' in this
fashion?

My perl is awful, but being solving problems like this is making it better,

Any ideas??


Miles D. Oliver
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.firemountain.net/pipermail/novalug/attachments/20120201/69669471/attachment.htm>


More information about the Novalug mailing list