Re: if: Expression syntax help in C shell





sorry - I posted too soon


Steve <javacc2@xxxxxxxxx> writes:

I got "if: Expression syntax" error when I executed this simple
script. I have no idea what went wrong. please help. thanks!!

#!/bin/csh

I suggest

#!/bin/csh -f

This protected your script from interacting with the user's ~/.cshrc file


setenv SRCPATH /home/test
if (/usr/bin/ls $SRCPATH | wc -l > 0) then

You should always put spaces after brackets with csh.
And you can't use pipes where csh wants an expression.

And if you want to test for the existance of files in a directory, I'd use

if ( -d "$SRCPATH" ) then
set count = ( `ls "$SRCPATH" | wc -l` )
else
echo directory $SRCPATH missing
exit
endif

if ( $count > 0 ) then
echo great 0
else
echo less 0
endif
.



Relevant Pages

  • Re: Disc space: How low can you go?
    ... here's a script that i use *a lot* for monitoring my systems. ... echo!calculates the amount of free space on the ... setvar _vf_volume ups ...
    (comp.sys.hp.mpe)
  • doy script
    ... i offered a script called 'doy' that had been part of tim ... echo req req req ... DOY also sets a ci variable ...
    (comp.sys.hp.mpe)
  • Re: [Full-disclosure] reduction of brute force login attempts via SSHthrough iptables --
    ... Anyhow its no problem at all to modify, so if you dont like it, just dont use it. ... on a lame script like this as long as it WORKS and is not insecure. ... echo "~ sorting out ip by ip" ... # echo "not enough failed logins, probably no attack from: ...
    (Full-Disclosure)
  • Ripping Tapes with Linux--How To
    ... the full script is located in the BASH ... My tape player is a portable style journalist's recorder from the ... The most irritating part of the recording process was setting the ... echo Starting de-noise procedure to file $TMP1 ...
    (comp.os.linux.misc)
  • Re: Linux Backup with Modification Date Filter?
    ... I wrote a bash script that acts as a wrapper to rsnapshot which first ... generates a modification-date filter, ...
    (comp.os.linux.misc)