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

Miles D. Oliver miles.d.oliver@gmail.com
Wed Feb 1 21:36:40 EST 2012


I forged ahead with a bash script that I can call from perl and pass the 3
variables I need.

I make one connection to get the user info from the DB and then compare
against LDAP.

Its not an ideal solution but given the limited capability of the CLI so
I'll have to make it work.
So far it has been working and i have to complete the error checking.

The Vendors CLI for this DB is horrible.

On Wed, Feb 1, 2012 at 4:13 PM, <sean@mcgowanet.com> wrote:

> Try something like this… you could make a function out of it to send a
> list of commands; however, you will have to parse the output yourself.
> This could also be accomplished by redirecting bash to a file and then
> reading that, but in any case, you are at the mercy of the output buffering
> of whatever process (in this case bash) to which you fork.  This can be
> somewhat of a nightmare, although I think that this will work since I
> believe bash output is line buffered.  Otherwise, you should use Expect, as
> previously mentioned.  This will simulate a tty.  You also can look in to
> IPC::open2.  Good luck.
>
>
>
> #!/usr/bin/perl -w
>
> use strict;
>
> my $pid = open OUT, "-|";
>
> my @output;
> if ($pid) {
>          #parent reads stdout from kid
>          @output = <OUT>;
> } else {
>          my $kidpid = open SHELL, "|/bin/bash";
>          print SHELL "export KITTENS=suck\n";
>          print SHELL 'echo $KITTENS' . "\n";
>          print SHELL "ls -ltr\n";
>          close SHELL;
>          waitpid($kidpid,0); #wait for shell to die
>          exit;
> }
>
> print "OUTPUT =\n", @output;
>
>
> Sent via BlackBerry by AT&T
>
> -----Original Message-----
> From: "Miles D. Oliver" <miles.d.oliver@gmail.com>
> Sender: novalug-bounces@calypso.tux.org
> Date: Wed, 1 Feb 2012 14:53:25
> To: Jon LaBadie<novalugml@jgcomp.com>
> Cc: <novalug@calypso.tux.org>
> Subject: Re: [Novalug] Perl calling multiple shell commands - wrapping my
>  head around it.
>
> _______________________________________________
> 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/5f4dd29c/attachment.htm>


More information about the Novalug mailing list