2008-06-10 03:32:46 my shell script run error!
Matthew Wang (CHINA)
Message: 56893
I create a shell script:
++++++++++++++++++++++++++++++++++++++
#!/bin/msh
# boaconfg.sh
# run it: sh boaconfig.sh
#
# download files
#
/bin/cd /tmp
/bin/tftp -r boa.conf -g 192.168.10.226
/bin/tftp -r index.html -g 192.168.10.226
#
# setup for boa server
#
mkdir /etc/boa
#echo "cp /tmp/boa.conf /etc/boa/"
cp /tmp/boa.conf /etc/boa/
mkdir -p /var/log/boa
mkdir /home/www
cp /tmp/index.html /home/www/
++++++++++++++++++++++++++++++++++++++
when I run it, the error info follows like:
root:/tmp> sh -n boaconfg.sh
root:/tmp> sh -x boaconfg.sh
+
: not found
+/bin/cd /tmp
/bin/cd: not found
+/bin/tftp -r boa.conf -g 192.168.10.226
+/bin/tftp -r index.html -g 192.168.10.226
+
: not found
+mkdir /etc/boa
': File existscreate directory '/etc/boa
+
: not found
+cp /tmp/boa.conf /etc/boa/
+
: not found
+mkdir -p /var/log/boa
+
: not found
+mkdir /home/www
': File existscreate directory '/home/www
+
: not found
+cp /tmp/index.html /home/www/
+
: not found
+
: not found
+
: not found
What does ":not found" mean?
I checked that cp did not be executed
TranslateQuoteReplyEditDelete
2008-06-10 06:06:34 Re: my shell script run error!
Yi Li (CHINA)
Message: 56921
What is the output of "sh --version"?
QuoteReplyEditDelete
2008-06-10 06:50:49 Re: my shell script run error!
Matthew Wang (CHINA)
Message: 56922
#sh --version
BusyBox v1.4.1 (2008-06-05 10:19:04 CST) Built-in shell (msh)
Enter 'help' for a list of built-in commands.
what I used is :
Linux version 2.6.22.9-ADI-2007R2-pre-svn3690 (root@localhost.localdomain) (gcc version 4.1.2 (ADI svn)) #590 Thu Jun 5 11:06:00 CST 2008
TranslateQuoteReplyEditDelete
2008-06-10 10:42:39 Re: my shell script run error!
Jonathan Kotta (UNITED STATES)
Message: 56931
"cd" is a shell built-in. There is no executable file named "cd" in /bin or anywhere else. The "help" bullt-in will give you a list of all the built-in commands.
QuoteReplyEditDelete
2008-06-10 23:40:10 Re: my shell script run error!
Matthew Wang (CHINA)
Message: 56953
root:/usr> help
Built-in commands:
-------------------
. : break cd continue eval exec exit export help login newgrp
read readonly set shift times trap umask wait
I modified the script like following:( used built-in cmds directly and gave the absolutely path of other cmds )
#!/bin/msh
# boaconfg.sh
# run it: sh boaconfig.sh
#
# download files
#
cd /tmp
/bin/tftp -r boa.conf -g 192.168.10.226
/bin/tftp -r index.html -g 192.168.10.226
#
# setup for boa server
#
/bin/mkdir /etc/boa
/bin/cp /tmp/boa.conf /etc/boa/
/bin/mkdir -p /var/log/boa
/bin/mkdir /home/www
/bin/cp /tmp/index.html /home/www/
HOWEVER, the result was that only tftp cmd was executed right and other cmds such as cd , mkdir and cp got wrong!!!
somebody said it might be related to msh!
when I executed "sh -n boaconfg.sh", it had no errors.
so my script is right, isn't it?
ANY HELP APPRECIATED!
TranslateQuoteReplyEditDelete
2008-06-11 00:50:37 Re: my shell script run error!
Mike Frysinger (UNITED STATES)
Message: 56956
there's no point in giving full paths to programs. your PATH should be set sanely to search /bin automatically.
QuoteReplyEditDelete
2008-06-11 02:02:19 回复: Re: my shell script run error!
Matthew Wang (CHINA)
Message: 56961
I'm sorry , COULD u give me a simple example, which is a simple shell script run well in msh?
THANK you
TranslateQuoteReplyEditDelete
2008-06-11 02:59:21 Re: 回复: Re: my shell script run error!
Yi Li (CHINA)
Message: 56964
do "cat /etc/rc" to see an example.
QuoteReplyEditDelete
2008-06-11 04:28:52 回复: Re: 回复: Re: my shell script run error!
Matthew Wang (CHINA)
Message: 56986
hey guys, I got further more info.
here it is, the shell script for example:
#!/bin/sh
# test.sh
echo "test.sh ..."
pwd
cd /tmp
date > ttime
cat ttime
=============
1)when I create it on PC, and then tftp it into the bf537 board, and exec "sh test.sh",
ERROR:
root:/tmp> sh test.sh
test.sh ...
: not found
: bad directory
root:/tmp>
2)when I create it on bf537 board with vi, and exec "sh test.sh",
SUCCESS:
root:/tmp> sh test.sh
test.sh ...
/tmp
Mon Jan 1 00:11:42 UTC 2007
root:/tmp>
WHAT IT MEANS?
TranslateQuoteReplyEditDelete
2008-06-11 04:47:56 Re: 回复: Re: 回复: Re: my shell script run error!
Yi Li (CHINA)
Message: 56992
What is your host PC? Are you using a Windows editor?
QuoteReplyEditDelete
2008-06-11 22:44:06 回复: Re: 回复: Re: 回复: Re: my shell script run error!
Matthew Wang (CHINA)
Message: 57054
Problem is solved!
I created the shell script in Windows with Ultraedit, not in Linux, so stupid mistake!