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

Miles D. Oliver miles.d.oliver at gmail.com
Wed Feb 1 14:53:25 EST 2012


The whole idea behind this is to create/delete users in the vendors DB from
the CLI based upon attributes in an LDAP OU.

Because of the way this nasty CLI works its probably just best to.

Call the CLI twice in the perl scrip with 'open()'

Once to get all the output of users and permissions from the Vendors DB all
at once, I can do this with a single single 'backtick' command.

Then do my comparisons of user permissions in the Vendor DB against the
LDAP OU.

Then pass the results of the comparison to a real bash script with
arguments to do the user and permission modifications in the Vendors DB.

I was hoping to do this in a single perl script for ease but the CLI is
very limited in what I can do with it.

The whole idea is to eliminate another Administration interface for user
management.






On Wed, Feb 1, 2012 at 1:50 PM, Jon LaBadie <novalugml at jgcomp.com> wrote:

> 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 at jgcomp.com
>  11226 South Shore Rd           (703) 787-0688 (H)
>  Reston, VA  20190              (609) 477-8330 (C)
> _______________________________________________
> Novalug mailing list
> Novalug at calypso.tux.org
> http://calypso.tux.org/mailman/listinfo/novalug
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://calypso.tux.org/pipermail/novalug/attachments/20120201/a3e08e3a/attachment.html 


More information about the Novalug mailing list