[TriLUG] bash weirdness
stan briggs
stanbriggs at gmail.com
Tue Apr 7 09:21:03 EDT 2009
all,
the answer was simple but crude. eval and exec each had their own subtleties
and quirks. instead, i manually spawn my own bash sub-process and provide it
the line that i want executed as a command line parameter. like this:
line="dpkg -l > all-packages.txt"
/bin/bash -c "$line"
this did exactly what i wanted it to do.
any feedback on the cons of doing it this way would be greatly appreciated.
also, i never really got any explanation on any links that explained why the
redirections caused issues.
thanks to all,
stan
On Tue, Apr 7, 2009 at 8:00 AM, Ron Young <ronyoung at nc.rr.com> wrote:
> Stan,
> This worked on my system:
>
> #!/bin/bash
>
> #line="dpkg -l > all-packages.txt";
> # my system does not have dpkg installed
>
>
> line=`ls -ln > line.txt`;
> echo $line;
>
> exec $line;
>
> cat line.txt
>
>
>
> Ron Young
> 919-621-9015
>
> +++++++++++++++++++
> Little tiny dreams require little tiny thoughts and little tiny steps.
> Great big dreams require great big thoughts and little tiny steps.
> +++++++++++++++++++
>
>
> On Mon, Apr 6, 2009 at 4:45 PM, stan briggs <stan at stanbriggs.com> wrote:
>
> > all,
> >
> > i'm trying to get a series of commands to execute with a bash shell.
> > someting like this:
> > line="dpkg -l > all-packages.txt"
> > which i then try to execute with
> > $line
> > `$line`
> > output=`$line`.
> > none seem to execute the command. i'm guessing it has to do with the pipe
> > symbol and explains why similar commands with shell re-directs in them
> > fail,
> > also.
> >
> > can anyone point me to a good reference that explains this?
> >
> > thanks,
> > stan
> >
> > --
> > Stan B. Briggs
> > +1-919-414-9513
> > +++++++++++++++++++
> > the oBoJ Foundation is the open source community coming together for the
> > benefit of society. our events and work are for the purpose of raising
> > awareness, raising funds, and performing activities for good causes.
> > participation is open to all who wish to support worthwhile public
> causes.
> > www.oBoJ.org
> > +++++++++++++++++++
> > Little tiny dreams require little tiny thoughts and little tiny steps.
> > Great big dreams require great big thoughts and little tiny steps.
> > +++++++++++++++++++
> > --
> > TriLUG mailing list :
> http://www.trilug.org/mailman/listinfo/trilug
> > TriLUG FAQ : http://www.trilug.org/wiki/Frequently_Asked_Questions
> >
> --
> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG FAQ : http://www.trilug.org/wiki/Frequently_Asked_Questions
>
--
Stan B. Briggs
+1-919-414-9513
+++++++++++++++++++
the oBoJ Foundation is the open source community coming together for the
benefit of society. our events and work are for the purpose of raising
awareness, raising funds, and performing activities for good causes.
participation is open to all who wish to support worthwhile public causes.
www.oBoJ.org
+++++++++++++++++++
Little tiny dreams require little tiny thoughts and little tiny steps.
Great big dreams require great big thoughts and little tiny steps.
+++++++++++++++++++
More information about the TriLUG
mailing list