if expression syntax error

if expression syntax error

Post by tgribbi » Sun, 16 Jan 2005 00:31:13



Hello,

I'm getting a snytax error in a file sourced within a csh script (in
some cases only) when the csh script is run by a Computer Associates job
load product called Autosys.  This if expression and error is within a
sourced file.  So script.csh has a command "source my_env.env".
my_env.env contains the if statement.

Below is the statement and error:
--
if ( $script_path =~ *sandbox* ) then
if: Expression syntax
--
(The expression tries to determine if the string contains "sandbox".
The complexity of the string seems to have some affect on success or
failure).

In some cases the if statment processes okay, sometimes we see the error
above when the load script runs through Autosys.

For example when $script path contains
"local/sandbox/meta/loads/wd/script.csh" it works fine through Autosys.

On the other hand when the $script_path string is more complex like
"/local/sandbox/meta/loads/wd/script2.csh param1 param2" we see the
error message above.

 From the command line it always works with either situation above.  The
script is defined as  #!/bin/csh -f.  The logged in user default shell
is /bin/tcsh.

Two questions:
1.  Does anyone have an idea what may be happening here?  I can't
understand why I am receiving the error in one case but not the other
since the *.csh scripts seem to identical to the point that the error
occurs.
And even if you don't...
2.  Does anyone know of an alternate expression that would be more
universally acceptable?  Due to a time constraint I would be happy to
just rewrite the expression, get it working and resolve the source of
the problem perhaps with vendor help later.

The current statement is:
if ( $script_path =~ *sandbox* ) then
....
else
...
endif

Thanks in advance for any help or insight!

Tim Gribbin
University at Buffalo

 
 
 

if expression syntax error

Post by Willia » Sun, 16 Jan 2005 01:33:34



Quote:> Hello,

> I'm getting a snytax error in a file sourced within a csh script (in
> some cases only) when the csh script is run by a Computer Associates job
> load product called Autosys.  This if expression and error is within a
> sourced file.  So script.csh has a command "source my_env.env".
> my_env.env contains the if statement.

> Below is the statement and error:
> --
> if ( $script_path =~ *sandbox* ) then
> if: Expression syntax

Does it work better if you write it as:

if ( "$script_path" =~ "*sandbox*" ) then

Without the quotes, I would expect it to work only if script_path
did NOT contain a space (or a few other special characters).
Quoting anything that might induce file globbing is also a good
idea. (Ever tried it in a directory that had a file whose name
contained 'sandbox'?) -Wm

 
 
 

if expression syntax error

Post by Rakesh Sharm » Sun, 16 Jan 2005 01:33:28



> Hello,

> I'm getting a snytax error in a file sourced within a csh script (in
> some cases only) when the csh script is run by a Computer Associates
job
> load product called Autosys.  This if expression and error is within
a
> sourced file.  So script.csh has a command "source my_env.env".
> my_env.env contains the if statement.

> Below is the statement and error:
> --
> if ( $script_path =~ *sandbox* ) then
> if: Expression syntax
> --
> (The expression tries to determine if the string contains "sandbox".
> The complexity of the string seems to have some affect on success or
> failure).

> In some cases the if statment processes okay, sometimes we see the
error
> above when the load script runs through Autosys.

Quote your variables.

if ( "$script_path" =~ *sandbox* ) then
# ............. pathA

else

# ............. pathB

endif

 
 
 

if expression syntax error

Post by Michael Tosc » Sun, 16 Jan 2005 05:29:16





>>Hello,

>>I'm getting a snytax error in a file sourced within a csh script (in
>>some cases only) when the csh script is run by a Computer Associates job
>>load product called Autosys.  This if expression and error is within a
>>sourced file.  So script.csh has a command "source my_env.env".
>>my_env.env contains the if statement.

>>Below is the statement and error:
>>--
>>if ( $script_path =~ *sandbox* ) then
>>if: Expression syntax

> Does it work better if you write it as:

> if ( "$script_path" =~ "*sandbox*" ) then

> Without the quotes, I would expect it to work only if script_path
> did NOT contain a space (or a few other special characters).
> Quoting anything that might induce file globbing is also a good
> idea. (Ever tried it in a directory that had a file whose name
> contained 'sandbox'?) -Wm

True that the variable needs "quoting", but in this case the globbing does not
happen in the token parser but inside the =~ operator, which is intended and
must not be escaped.

So correct is what Rakesh Sharma suggested:

if ( "$script_path" =~ *sandbox* ) then

This is quite different from

if ( "$script_path" == "*sandbox*" ) then

where the globbing happens in the token parser, and files in the current
directory are matched.
Not logical? So is C-shell.

--

 
 
 

if expression syntax error

Post by Willia » Tue, 18 Jan 2005 03:25:56



Quote:> True that the variable needs "quoting", but in this case the globbing does
not
> happen in the token parser but inside the =~ operator, which is intended
and
> must not be escaped.

> So correct is what Rakesh Sharma suggested:

> if ( "$script_path" =~ *sandbox* ) then

> This is quite different from

> if ( "$script_path" == "*sandbox*" ) then

> where the globbing happens in the token parser, and files in the current
> directory are matched.
> Not logical? So is C-shell.

One reason I don't use c shell. Didn't know that about
the =~ operator. Live and learn (and avoid :-)  -Wm
 
 
 

1. access.conf syntax error without a syntax error

Hi:

I just compiled Apache 1.3.0 on a RISC/6000 running AIX 4.3.1

After launching httpd I get the following error:

Syntax error on line 23 of /usr/local/http/../access.conf
Expected </Directory> but saw </Directory>

I checked the file and looks normal (no unexpected eof or things like
that). I have not modified the access.conf file so I could not have
introduced any syntax errors.

Any clues ? I am totally clueless.

Thanks in advance.

Ricardo

2. Intel motherboard (D845PEBT2) compatibility with Linux/FreeBSD?

3. Correct Syntax for configuring IFS shell variable ?

4. Problems installing SuSE Linux 5.2 with LS-120

5. inline assembler error - porting Intel syntax to AT&T syntax

6. HELP ME

7. Regular Expression Syntax Limitation?

8. FAQ: SCO UNIX newsgroups and mailing lists

9. Help with samples of regular expressions syntax please

10. tcsh Controlling Expressions Syntax

11. @: Expression syntax

12. if :Expression Syntax problem at login

13. Need to know correct syntax for conditional expression