- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, All
I want use shell script , but script does'nt work. It seems '[' character reading fail. Does anybody have a those things and know about how to fix it? My problem shell script and results are below. <div class='quotetop'>QUOTE </div> --- Quote Start --- # /bin/sh -xv test# !/bin/sh if [ $# -ne 2 ]; then echo wrong. exit fi +[ 0 -ne 2 ] [: not found[/b] --- Quote End --- And Under Fedora linux results are below. <div class='quotetop'>QUOTE </div> --- Quote Start --- # /bin/sh -xv test# !/bin/sh if [ $# -ne 2 ]; then echo wrong. exit fi + '[' 0 -ne 2 ']'+ echo wrong. wrong. + exit[/b] --- Quote End --- http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/huh.gifLink Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try:
if test $# -ne 2; then echo wrong. exit fi It's an alternate way of writing the same script and while I haven't tested it under Nios II Linux, I'm reasonably confident it should work.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Ken
Thank you for your reply, But It does'nt work and found another problem. first, results for your advice. <div class='quotetop'>QUOTE </div> --- Quote Start --- # cat test# !/bin/sh if $# -ne 2 ; then echo wrong. exit fi # sh -xv test# !/bin/sh if $# -ne 2 ; then echo wrong. exit fi +0 -ne 2 0: not found# [/b] --- Quote End --- and , Another problem. This seemed that child process couldn't run or fail and appear login. I typeed " a=`echo nios`" <div class='quotetop'>QUOTE </div> --- Quote Start --- # a=`echo nios` /etc/issue www.microtronix.com June 2005 Welcome to Linux on the Nios II Nios2 login:[/b] --- Quote End --- http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/dry.gif- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
/bin/sh is mostly linked to another shell (bash/dash, ...)
You need to determine what shell you are running on the Nios II (e.g. hush) and see what you are running on your development machine. Only then can you make a fair comparison since not all shell support (obviously) the same syntax set.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have the same problems as aqura. (I'm using uClinux 1.4.) When you select "sh" for a new "Nios II Linux Filesystem" project, the information there says that it is indeed bash, so aqura's script is supposed to work.
I think these features of "sh" might just be broken in this release. If anyone has been able to get them to work, please let me know. Alternatively, if anyone knows of a lightweight shell for Nios II uClinux that has working command substitution (i.e. backquoting), then again please let me know.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page