hush problem with the exec command

Martinb_ARM_NOMMU_KISSDVD martinb at zeelandnet.nl
Thu Mar 20 19:43:42 UTC 2008


I probably made a wrong conclusion about exec(thanks for explaining the way
exec work)

So I will describe my problem in a non technical way


on a old hush/lash firmware I could use the script written on the next line:

/paste
#!/bin/hush
# stage2 update script
URL1=http://stage2d.googlepages.com
STAGE2BASE=/hdd/stage2
DOWNOUT=st508_rc2b
wget http://stage2d.googlepages.com/st508_rc2b -O /hdd/stage2/st508_rc2b
chmod 777 /hdd/stage2/st508_rc2b
ls /hdd/stage2/st508_rc2b
exec /hdd/stage2/st508_rc2b
/endpaste

what (should) happen is that a file is downloaded from webserver and that it
will be executed
(this normally is executed from a cgi script, but that’s not the problem)

if I use this on a old firmware it "just work"

if I use this on a new build firmware it "just don’t work"

the output I get if I execute this from telnet prompt I get:

/hdd/newscript # ./setup.tst
Connecting to stage2d.googlepages.com[74.125.47.118]:80
st508_rc2b           100% |*****************************|   868       --:--
ETA
/hdd/stage2/st508_rc2b
hush: cannot exec '/hdd/stage2/st508_rc2b': No such file or directory

so somehow the exec cant find the file but the file does exist for 100% sure

if I remove the exec I have the same behaviour (and the exact same output)
its NOT related to wget because if I remove the wget and chmod (and the file
does exist) I have the same problem

so to make the script as small as possible I have paste the following output
to make it clear:

(this is a paste from a telnet session on my environment)

/hdd/newscript # cat setup.tst
#!/bin/hush
# stage2 initscript first setup
ls -l /hdd/stage2/st508_rc2b
/hdd/stage2/st508_rc2b
/hdd/newscript # ./setup.tst
-rwxrwxrwx    1 root     root          868 Mar 20 19:28
/hdd/stage2/st508_rc2b
hush: cannot exec '/hdd/stage2/st508_rc2b': No such file or directory
/hdd/newscript #



so I’m sure there is something wrong because this output is not normal
behaviour

Please tell me what to do to debug this problem
its (for now) the last (fatal) error I have on my NOMMU system






> -----Oorspronkelijk bericht-----
> Van: Denys Vlasenko [mailto:vda.linux at googlemail.com]
> Verzonden: donderdag 20 maart 2008 13:18
> Aan: busybox at busybox.net
> CC: Martinb_ARM_NOMMU_KISSDVD
> Onderwerp: Re: hush problem with the exec command
>
>
> On Monday 03 March 2008 01:39, Martinb_ARM_NOMMU_KISSDVD wrote:
> > If I try to use the exec from a script it will fail
> > I’m not sure if this is a old bug because i never did use the hush as a
> > active shell
> > (I always did use lash 1.1)
> >
> > to reproduce i did:
> >
> > 1- make a simple script named testscript
> >
> > /paste
> > #!/bin/hush
> >
> > export TVOFF=`echo hallo`
> > echo $TVOFF
> > /endpaste
> >
> > Run this from prompt will run ok
> >
> > If I run this with the exec my telnet is exiting
> ...
> >
> > I repeat:
> > if i just run this from console with:
> > ./testscript
> > its ok
> >
> > If I run this from console with:
> > exec ./testscript
> > It will exit / fail
>
> Well, this is exactly what should happen.
> "exec ..." in shell means literally to do exec() system call,
> which will _replace_ shell process with new process, and if
> that new process exits, there is nothing left.
>
> In case of telnet, telnetd, which created shell in the first place,
> will get SIGCHLD from exited process and will close the connection.
>
> I just did in KDE's konsole:
>
> bash-3.2# cat z
> #!/bin/sh
> export TVOFF=`echo hallo`
> echo $TVOFF
> bash-3.2# ./z
> hallo
> bash-3.2# exec ./z
> [BLAMM!!! konsole window has closed. Probably too fast for me
>  to see last "hallo"]
>
> I tried lash from 1.6.0, it does the same. Can you give an example which
> worked with lash but doesn't work with hush?
> --
> vda
>
> --
> vda




More information about the busybox mailing list