Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

sh doesn't work ?

Altera_Forum
Honored Contributor II
1,221 Views

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 

+ &#39;[&#39; 0 -ne 2 &#39;]&#39;+ echo wrong. 

wrong. 

+ exit[/b] 

--- Quote End ---  

 

 

http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/huh.gif
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
527 Views

Try: 

 

if test $# -ne 2; then 

echo wrong. 

exit 

fi 

 

It&#39;s an alternate way of writing the same script and while I haven&#39;t tested it under Nios II Linux, I&#39;m reasonably confident it should work.
0 Kudos
Altera_Forum
Honored Contributor II
527 Views

Hi, Ken 

 

Thank you for your reply, But It does&#39;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&#39;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
0 Kudos
Altera_Forum
Honored Contributor II
527 Views

/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.
0 Kudos
Altera_Forum
Honored Contributor II
527 Views

I have the same problems as aqura. (I&#39;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&#39;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.
0 Kudos
Reply