Unix Programming - "is not an identifier"

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > May 2006 > "is not an identifier"





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author "is not an identifier"
John Smith

2006-05-10, 1:17 pm

i have the following ~/S1/C1.sh

#!/usr/bin/sh

.. $HOME/include2.ksh

....

$HOME/include2.ksh has the following line:

#!/bin/ksh

....

export VAR1=/dir1/app1


in ~/S1, I ran C1.sh as follows:
../C1.sh

I got the following error:
../C1.sh: VAR1=/dir/app1: is not an identifier

how to solve this problem without changing the fact that C1.sh is a sh
script, and include2.ksh is a ksh script?

Jim Cochrane

2006-05-10, 1:17 pm

On 2006-05-10, John Smith <wleung7@gmail.com> wrote:
> i have the following ~/S1/C1.sh
>
> #!/usr/bin/sh
>
> . $HOME/include2.ksh
>
> ...
>
> $HOME/include2.ksh has the following line:
>
> #!/bin/ksh
>
> ...
>
> export VAR1=/dir1/app1
>
>
> in ~/S1, I ran C1.sh as follows:
> ./C1.sh
>
> I got the following error:
> ./C1.sh: VAR1=/dir/app1: is not an identifier
>
> how to solve this problem without changing the fact that C1.sh is a sh
> script, and include2.ksh is a ksh script?
>


Try changing:

export VAR1=/dir1/app1

to:

VAR1=/dir1/app1
export VAR1


--


*** Posted via a free Usenet account from http://www.teranews.com ***
John Smith

2006-05-10, 1:17 pm

> Try changing:
>
> export VAR1=/dir1/app1
>
> to:
>
> VAR1=/dir1/app1
> export VAR1


It works. but why?

Jim Cochrane

2006-05-10, 7:15 pm

On 2006-05-10, John Smith <wleung7@gmail.com> wrote:
>
> It works. but why?
>


Because of the way you structured your scripts, the VAR1 assignment ends up
being executecd by sh, not ksh. sh (the Bourne shell) does not understand
the 'export var=x' syntax. (ksh, of course, does.)

--


*** Posted via a free Usenet account from http://www.teranews.com ***
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com