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

Miles D. Oliver miles.d.oliver@gmail.com
Wed Feb 1 11:27:34 EST 2012


AS HE BANGS HIS HEAD AGAINST THE DESK...

Its just that easy...

THANK YOU!!!   JUST WHAT I NEEDED.



On Wed, Feb 1, 2012 at 11:14 AM, <sean@mcgowanet.com> wrote:

> Yes. You could use:
> open SHELL, "| /bin/bash";
> print SHELL $cmd1;
> print SHELL $cmd2;
> ...
> print SHELL $cmdn;
> close SHELL;
>
> Note that you will have to send an explicit eol ("\n") with each command,
> but I think that will do what you are looking for.
> Sent via BlackBerry by AT&T
>
> -----Original Message-----
> From: Keith Howell <keith.c.howell@gmail.com>
> Sender: novalug-bounces@calypso.tux.org
> Date: Wed, 01 Feb 2012 08:47:14
> To: <novalug@calypso.tux.org>
> Subject: Re: [Novalug] Perl calling multiple shell commands - wrapping my
>  head around it.
>
> Been a long time since I had to play with this stuff.
>
> Can you call the open() as a network connection open? That way you would
> have a file handle that you can use in the rest of your script. Then
> close it down when you are done.
>
> If it is a daemon that is listening on the remote machine, then you
> should be able to keep it open somehow.
>
> --
> Keith
>
> On 02/01/2012 08:13 AM, Miles D. Oliver wrote:
> > 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
> >
> >
> >
> >
> >
> >
> > _______________________________________________
> > Novalug mailing list
> > Novalug@calypso.tux.org
> > http://calypso.tux.org/mailman/listinfo/novalug
>
> _______________________________________________
> Novalug mailing list
> Novalug@calypso.tux.org
> http://calypso.tux.org/mailman/listinfo/novalug
> _______________________________________________
> Novalug mailing list
> Novalug@calypso.tux.org
> http://calypso.tux.org/mailman/listinfo/novalug
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.firemountain.net/pipermail/novalug/attachments/20120201/cbb4f81d/attachment.htm>


More information about the Novalug mailing list