| Summary: | Error running some shell scripts directly | ||
|---|---|---|---|
| Product: | Busybox | Reporter: | jabba.nalhutta |
| Component: | Other | Assignee: | unassigned |
| Status: | RESOLVED INVALID | ||
| Severity: | minor | CC: | busybox-cvs |
| Priority: | P5 | ||
| Version: | 1.19.x | ||
| Target Milestone: | --- | ||
| Hardware: | Other | ||
| OS: | Linux | ||
| Host: | Target: | ||
| Build: | |||
| Attachments: |
The .config file for the bug
strace log |
||
|
Description
jabba.nalhutta
2011-09-06 14:23:47 UTC
Can't reproduce. In my testing, a shell script w/o "#!interpreter" 1st line _can_ be successfully run from ash command line I can reproduce it very easily. Perhaps you're not running busybox as the shell and/or default interpreter. Here is a screenshot with me trying to run two scripts, "foo.sh" and "bar" (see below): router@Ubuntu ~/busybox-1.19.2 $ ./ash BusyBox v1.19.2 (2011-09-10 06:29:23 BST) built-in shell (ash) Enter 'help' for a list of built-in commands. router@Ubuntu ~/busybox-1.19.2 $ help Built-in commands: ------------------ . : [ [[ alias bg break cd chdir continue echo eval exec exit export false fg hash help jobs kill let local printf pwd read readonly return set shift source test times trap true type ulimit umask unalias unset wait router@Ubuntu ~/busybox-1.19.2 $ ./foo.sh This is foo.sh calling bar ... ./foo.sh: line 4: ./bar: not found Back to foo.sh router@Ubuntu ~/busybox-1.19.2 $ ./bar ./ash: ./bar: not found router@Ubuntu ~/busybox-1.19.2 $ exit router@Ubuntu ~/busybox-1.19.2 $ ----- here are the test scripts (foo.sh) ------ #!./ash echo "This is foo.sh" echo "calling bar ..." ./bar echo "Back to foo.sh" ---- bar ---- echo "This is bar" echo "Finished running bar" ---- this is is what the output should look like ---- router@Ubuntu ~/busybox-1.19.2 $ ./foo.sh This is foo.sh calling bar ... This is bar Finished running bar Back to foo.sh router@Ubuntu ~/busybox-1.19.2 $ (In reply to comment #2) > router@Ubuntu ~/busybox-1.19.2 > $ ./foo.sh > This is foo.sh > calling bar ... > ./foo.sh: line 4: ./bar: not found > Back to foo.sh > router@Ubuntu ~/busybox-1.19.2 > $ ./bar > ./ash: ./bar: not found > router@Ubuntu ~/busybox-1.19.2 > $ exit > router@Ubuntu ~/busybox-1.19.2 > $ Can't reproduce. I am getting: /bin # ./foo.sh This is foo.sh calling bar ... This is bar Finished running bar Back to foo.sh If I do "chmod 644 bar", I am getting: /bin # ./foo.sh This is foo.sh calling bar ... ./foo.sh: line 4: ./bar: Permission denied Back to foo.sh Thus, I am puzzled how you end up getting "./bar: not found". Please, (1) attach your .config file to this bug, and (2) run "strace -oLOG -s999 -tt -f ./ash", run ./foo.sh under it, then exit the shell and attach resulting LOG file to this bug. (If you don't have strace tool, download one for your architecture from http://landley.net/aboriginal/downloads/binaries/extras/) Created attachment 3577 [details]
The .config file for the bug
Created attachment 3583 [details]
strace log
From your .config:
CONFIG_BUSYBOX_EXEC_PATH="./dist"
which looks wrong to me. It's usually "/proc/self/exe", "/bin/busybox" or similar. Why did you set it to "./dist"? I mean, it's a _relative_ path!?
From LOG:
10634 20:13:23.989951 execve("./bar", ["./bar"], [/* 43 vars */]) = -1 ENOEXEC (Exec format error)
Now ash tries to exec itself... using CONFIG_BUSYBOX_EXEC_PATH:
10634 20:13:23.990113 execve("./dist", ["ash", "./bar"], [/* 43 vars */]) = -1 ENOENT (No such file or directory)
and not surprisingly, "./dist" doesn't exist, and execve fails.
10634 20:13:23.990262 write(2, "./foo.sh: "..., 10) = 10
10634 20:13:23.990312 write(2, "line 4: "..., 8) = 8
10634 20:13:23.990361 write(2, "./bar: not found"..., 16) = 16
10634 20:13:23.990414 write(2, "\n"..., 1) = 1
I see. User error. Sorry to have disturbed you :-( |