Skip to main content
added 47 characters in body
Source Link
heemayl
  • 58.2k
  • 9
  • 129
  • 144

I am trying to write a c-shell script that checks for number of arguments and echos a string, but I am getting an unexpected end of file syntax error and I don't understand why.

Here is what I tried:

if ( $#argv == 0 ) then echo "Enter one or more args" else echo "Entry accepted" endif

if ( $#argv == 0 ) then
echo "Enter one or more args"
else
echo "Entry accepted"
endif

Later I tried to output each argument found with this:

if ( $#argv == 0 ) then echo "Enter one or more args" else foreach arg ( $* ) echo "Found argument $arg" end endif

if ( $#argv == 0 ) then
echo "Enter one or more args"
else
  foreach arg ( $* )
    echo "Found argument $arg"
  end 
endif

and got a different syntax error "unexpected token `(' "'"

Any help is appreciated

I am trying to write a c-shell script that checks for number of arguments and echos a string, but I am getting an unexpected end of file syntax error and I don't understand why.

Here is what I tried:

if ( $#argv == 0 ) then echo "Enter one or more args" else echo "Entry accepted" endif

Later I tried to output each argument found with this:

if ( $#argv == 0 ) then echo "Enter one or more args" else foreach arg ( $* ) echo "Found argument $arg" end endif

and got a different syntax error "unexpected token `(' "

Any help is appreciated

I am trying to write a c-shell script that checks for number of arguments and echos a string, but I am getting an unexpected end of file syntax error and I don't understand why.

Here is what I tried:

if ( $#argv == 0 ) then
echo "Enter one or more args"
else
echo "Entry accepted"
endif

Later I tried to output each argument found with this:

if ( $#argv == 0 ) then
echo "Enter one or more args"
else
  foreach arg ( $* )
    echo "Found argument $arg"
  end 
endif

and got a different syntax error "unexpected token `('"

Any help is appreciated

Source Link

C Shell Script syntax error "unexpected end of of file"

I am trying to write a c-shell script that checks for number of arguments and echos a string, but I am getting an unexpected end of file syntax error and I don't understand why.

Here is what I tried:

if ( $#argv == 0 ) then echo "Enter one or more args" else echo "Entry accepted" endif

Later I tried to output each argument found with this:

if ( $#argv == 0 ) then echo "Enter one or more args" else foreach arg ( $* ) echo "Found argument $arg" end endif

and got a different syntax error "unexpected token `(' "

Any help is appreciated