1835220 Members
2538 Online
110078 Solutions
New Discussion

C-Shell programming

 
Bettina Ofner
Advisor

C-Shell programming

Who can I use the following command line command in a C-shell:
. catiaenv /usr/home/USER.dcls
The point and the blank make me big troubles.
Thanks
Bettina
4 REPLIES 4
federico_3
Honored Contributor

Re: C-Shell programming


normally, when you execute a shell program, a subshell is created in which to execute it. therefore, if you define variables in the program, they are only good for as long as the program is executing( when the program in done, you return to the current shell's environment ). If you want to have the shell program executed in the current shell ( the defined vars will be good for the current shell's env. ) , use the "dot"command :

#. scriptname

I hope this helps you!


Federico

Dan Hetzel
Honored Contributor

Re: C-Shell programming

Hi Bettina,

the '.' command in Korn, Bourne or Posix shell means that the following argument has to be executed in the same shell as the calling shell, not by forking another subshell.

The C shell equivalent is 'source filename'.

You have to make sure that the content of the argument file can be interpreted by the C Shell, which would be surprising.

'Sourcing' a document is usually done to setup some environment variables (like in your .profile or .kshrc files) and the syntax for setting such variables differ between C shell and Bourne, Korn or Posix Shells.

in csh:
setenv VARNAME value
in sh and ksh:
export VARNAME=value

Hope this helps,

Best regards,

Dan
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
Andreas Voss
Honored Contributor

Re: C-Shell programming

Hi,

the line
. catiaenv /usr/home/USER.dcls
is bourne/korn shell syntax.
It is used to source environment into the current shell.
In c-shell the equivalent is the function source.
The source function uses the next argument as a file for input.
So the problem i see is that your line
. catiaenv /usr/home/USER.dcls
will execute the program/script catiaenv with a parameter and i don't know how to make this in c-shell.
Also it may be the case that the catiaenv itself uses bourne/korn shell syntax for setting environment variable which also differs from c-shell syntax ie:
Bourne/korn-shell: export VAR=VALUE
C-shell: setenv VAR VALUE

Hope this gives you a litte light.

Regards
Shannon Petry
Honored Contributor

Re: C-Shell programming

You CAN NOT DO THIS!

I know what your trying to do, and it will NOT work as is. CATIA looks for the users home directory to be /bin/ksh (IBM AIX default shell). The CATIA environment files are written for borne and korne shell. If you want to have a cshell login for these users and still access those files, they need to be copied and modified for cshell.
There are many differences in the way the shells set and define variables, use conditional statements, etc...
I.E.
# C-Shell
setenv CATCUST /home/catadm
# Borne, Korne, POSIX
CATCUST=/home/catadm
export CATCUST
The latter case is how the CATIA environment and declaration files are build.

I would NOT recommend that you pursue developing these scripts in c-shell because there are so many dependancies on the shell and the environment variables that you would be rewriting a whole lot of catia scripts (100's or more).

Best thing to do with CATIA is to keep the users in either ksh or sh for their default shell.

Regards,
Shannon
Microsoft. When do you want a virus today?