|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello netties,
guess that the solution is really straightforward, but may be I am just too blind at the moment: I want to run a list of commands by executing a new Bourne shell instance on one line. My testcode looks as follows: > cat testscript.sh echo hello TESTVAR="This is a test" export TESTVAR When I run a new shell and supply the list "manually" to the shell I can comprise them using braces without problems: > /bin/sh > { . testscript.sh ; echo $TESTVAR; } hello This is a test If I try to do it "in one run" it does not work as I would like it to work: > /bin/sh { . testscript.sh echo $TESTVAR; } syntax error: `}' unexpected > Is there a way in Bourne shell to accomplish execution (better: sourcing) of a shell script, and let subsequent commands being executed in the same environment as the script in the way indicated above without supplying the list interactively to the shell (but like a "/bin/sh -c" invocation? (which, BTW, does not work either)) . Cheers Bernd |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Sep 4, 4:43 pm, bernd <bew...@gmx.net> wrote:
> Hello netties, > > guess that the solution is really straightforward, but may be I am > just too blind at the moment: > > I want to run a list of commands by executing a new Bourne shell > instance on one line. My testcode looks as follows: > > > cat testscript.sh > > echo hello > TESTVAR="This is a test" > export TESTVAR > > When I run a new shell and supply the list "manually" to the shell I > can comprise them using braces without problems: > > > /bin/sh > > { . testscript.sh ; echo $TESTVAR; } > > hello > This is a test > > If I try to do it "in one run" it does not work as I would like it to > work: > > > /bin/sh { . testscript.sh echo $TESTVAR; } > > syntax error: `}' unexpected > > > > Is there a way in Bourne shell to accomplish execution (better: > sourcing) of a shell script, and let subsequent commands being > executed in the same environment as the script in the way indicated > above without supplying the list interactively to the shell (but like > a "/bin/sh -c" invocation? (which, BTW, does not work either)) . > > Cheers > > Bernd try this: /bin/sh -c 'myname=boogie;export myname;echo ${myname}' boogie be sure to use single quotes |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On 4 Sep., 16:21, hyperboogie <hyperboo...@gmail.com> wrote:
> On Sep 4, 4:43 pm, bernd <bew...@gmx.net> wrote: > > > > > > > Hello netties, > > > guess that the solution is really straightforward, but may be I am > > just too blind at the moment: > > > I want to run a list of commands by executing a new Bourne shell > > instance on one line. My testcode looks as follows: > > > > cat testscript.sh > > > echo hello > > TESTVAR="This is a test" > > export TESTVAR > > > When I run a new shell and supply the list "manually" to the shell I > > can comprise them using braces without problems: > > > > /bin/sh > > > { . testscript.sh ; echo $TESTVAR; } > > > hello > > This is a test > > > If I try to do it "in one run" it does not work as I would like it to > > work: > > > > /bin/sh { . testscript.sh echo $TESTVAR; } > > > syntax error: `}' unexpected > > > Is there a way in Bourne shell to accomplish execution (better: > > sourcing) of a shell script, and let subsequent commands being > > executed in the same environment as the script in the way indicated > > above without supplying the list interactively to the shell (but like > > a "/bin/sh -c" invocation? (which, BTW, does not work either)) . > > > Cheers > > > Bernd > > try this: > /bin/sh -c 'myname=boogie;export myname;echo ${myname}' > boogie > > be sure to use single quotes- Zitierten Text ausblenden - > > - Zitierten Text anzeigen - It works. Thanks a lot! |
|
![]() |
| Outils de la discussion | |
|
|