What is wrong with my shell script ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mmanjul
    New Member
    • Feb 2007
    • 7

    What is wrong with my shell script ?

    When I try to run my script(check.sh ) I get the following message:

    ./check.sh[3]: test: argument expected

    What does the above message mean ? I have used the arguments while trying to run this.Following is the contents of the script:

    1 #! /usr/bin/ksh
    2
    3 while [ "$1" != ""] ;
    4 do
    5 echo "Enter the name of the directory :"
    6 read dirname
    7 ls $dirname
    8
    9 echo "Press a key ..."
    10 read
    11 exit 0
    12 done ;
    13
    14
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    I don't have ksh installed on my machine, but when I ran this with bash, it worked fine. Try changing the shell to /bin/bash and see if it works for you too.

    Comment

    • horace1
      Recognized Expert Top Contributor
      • Nov 2006
      • 1510

      #3
      there appear to be a space missing before the ] in
      Code:
           3  while [ "$1" != ""] ;

      Comment

      • Varun Gupta
        New Member
        • Feb 2007
        • 13

        #4
        ya there is a space expected just before ]

        and what you are trying to do with "exit 0" within the while loop, without some condition. Does it work as you desire. ?

        Comment

        Working...