Discussion:
Busybox shell scripting
Joshua ChaitinPollak
2006-01-16 16:07:18 UTC
Permalink
Hello,

I'm trying to write a few init scripts for use with Busybox, and I
just discovered the 'source' command is not available with ash. Is
there a workaround method to import variables into currently running
scripts and to run sub-scripts without spawning more copies of ash?

Thanks,

-Josh
Yann E. MORIN
2006-01-16 16:16:09 UTC
Permalink
Post by Joshua ChaitinPollak
I'm trying to write a few init scripts for use with Busybox, and I
just discovered the 'source' command is not available with ash. Is
there a workaround method to import variables into currently running
scripts and to run sub-scripts without spawning more copies of ash?
A single dot '.' will do the trick. At least I do that and it works.
Example below:

#!/bin/ash
. /etc/sysconfig/foobar.cfg
if [ "$FOOBAR_OPT" = "y" ]; then
foobarize buz
fi

Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +0/33 662376056 | Software Designer | \ / CAMPAIGN | ^ |
| --==< ?_? >==-- ?---.----------------: X AGAINST | /e\ There is no |
| web: ymorin.free.fr | ***@home 3808 | / \ HTML MAIL | """ conspiracy. |
?---------------------?----------------?------------------?--------------------?
Joshua ChaitinPollak
2006-01-16 18:35:17 UTC
Permalink
Post by Yann E. MORIN
Post by Joshua ChaitinPollak
I'm trying to write a few init scripts for use with Busybox, and I
just discovered the 'source' command is not available with ash. Is
there a workaround method to import variables into currently running
scripts and to run sub-scripts without spawning more copies of ash?
A single dot '.' will do the trick. At least I do that and it works.
#!/bin/ash
. /etc/sysconfig/foobar.cfg
if [ "$FOOBAR_OPT" = "y" ]; then
foobarize buz
fi
Regards,
Yann E. MORIN.
Thanks, thats exactly what I needed.
--
Joshua ChaitinPollak
Software Engineer
Kiva Systems
Cristian Ionescu-Idbohrn
2006-01-16 18:56:11 UTC
Permalink
Post by Joshua ChaitinPollak
Post by Yann E. MORIN
Post by Joshua ChaitinPollak
I'm trying to write a few init scripts for use with Busybox, and I
just discovered the 'source' command is not available with ash. Is
there a workaround method to import variables into currently running
scripts and to run sub-scripts without spawning more copies of ash?
A single dot '.' will do the trick. At least I do that and it works.
Thanks, thats exactly what I needed.
Or:

# alias source='.'

should do the trick too.


Cheers,
Cristian
Cristian Ionescu-Idbohrn
2006-01-16 20:56:03 UTC
Permalink
Post by Joshua ChaitinPollak
Post by Yann E. MORIN
Post by Joshua ChaitinPollak
I'm trying to write a few init scripts for use with Busybox, and I
just discovered the 'source' command is not available with ash. Is
there a workaround method to import variables into currently running
scripts and to run sub-scripts without spawning more copies of ash?
A single dot '.' will do the trick. At least I do that and it works.
Thanks, thats exactly what I needed.
Or:

# alias source='.'

should do the trick too.


Cheers,
Cristian

Joshua ChaitinPollak
2006-01-16 20:35:13 UTC
Permalink
Post by Yann E. MORIN
Post by Joshua ChaitinPollak
I'm trying to write a few init scripts for use with Busybox, and I
just discovered the 'source' command is not available with ash. Is
there a workaround method to import variables into currently running
scripts and to run sub-scripts without spawning more copies of ash?
A single dot '.' will do the trick. At least I do that and it works.
#!/bin/ash
. /etc/sysconfig/foobar.cfg
if [ "$FOOBAR_OPT" = "y" ]; then
foobarize buz
fi
Regards,
Yann E. MORIN.
Thanks, thats exactly what I needed.
--
Joshua ChaitinPollak
Software Engineer
Kiva Systems
Joshua ChaitinPollak
2006-01-16 17:35:09 UTC
Permalink
Hello,

I'm trying to write a few init scripts for use with Busybox, and I
just discovered the 'source' command is not available with ash. Is
there a workaround method to import variables into currently running
scripts and to run sub-scripts without spawning more copies of ash?

Thanks,

-Josh
Yann E. MORIN
2006-01-16 18:29:17 UTC
Permalink
Post by Joshua ChaitinPollak
I'm trying to write a few init scripts for use with Busybox, and I
just discovered the 'source' command is not available with ash. Is
there a workaround method to import variables into currently running
scripts and to run sub-scripts without spawning more copies of ash?
A single dot '.' will do the trick. At least I do that and it works.
Example below:

#!/bin/ash
. /etc/sysconfig/foobar.cfg
if [ "$FOOBAR_OPT" = "y" ]; then
foobarize buz
fi

Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +0/33 662376056 | Software Designer | \ / CAMPAIGN | ^ |
| --==< ?_? >==-- ?---.----------------: X AGAINST | /e\ There is no |
| web: ymorin.free.fr | SETI at home 3808 | / \ HTML MAIL | """ conspiracy. |
?---------------------?----------------?------------------?--------------------?
Continue reading on narkive:
Loading...