How to invoke a login csh?

How to invoke a login csh?

Post by Fei Che » Sun, 18 Feb 2001 03:24:50



This is a bit silly, but I couldn't figure out how to invoke a csh as
a login shell. The OS is
SunOS 5.7 Generic_106541-14 sun4u sparc SUNW,Ultra-4

With the version of csh that came with Linux Redhat 6.2 , I can do "csh -l"
and everything is fine, but there's not this option for the csh on the
SunOS

I actually don't know how to find out which version of csh I'm using...
On csh, is there something of the equivalent of
% echo $ZSH_VERSION
3.1.9

Thanks in advance,

fei

 
 
 

How to invoke a login csh?

Post by Sven Maschec » Sun, 18 Feb 2001 03:44:06


 > With the version of csh that came with Linux Redhat 6.2 ,
 > I can do "csh -l"

Because it actually is a tcsh.

 > but there's not this option for the csh on the SunOS

Yes, csh (like ksh) has to be invoked with a dash as first character
in argv[0], '-csh'.

 - Either make a soft/hardlink with this name and have the according
   directory in your PATH as there mustn't be more leading characters.
   (ksh knows better here, btw)

 - Or invoke csh as login shell with a c program, the way login(1) does:

   execlp ("/usr/bin/sh", "-csh", (char*)NULL);

   Improve the above, if you want to supply more arguments.

Guessing: Perhaps your login scripts are not optimal, so that you feel
the need to always source .login?

You *really* want to use csh(1) instead of tcsh(1)?
Compile tcsh yourself or get a precompiled package.

 > I actually don't know how to find out which version of csh I'm using...

There is no easy way, no real versioning and it doesn't really matter.

Sven

 
 
 

How to invoke a login csh?

Post by Sven Maschec » Sun, 18 Feb 2001 07:08:35


 > With the version of csh that came with Linux Redhat 6.2 ,
 > I can do "csh -l"

Because it actually is a tcsh.

 > but there's not this option for the csh on the SunOS

Yes, csh (like ksh) has to be invoked with a dash as first character
in argv[0], '-csh'.

 - Either make a soft/hardlink with this name and have the according
   directory in your PATH as there mustn't be more leading characters.
   (ksh knows better here, btw)

 - Or invoke csh as login shell with a c program, the way login(1) does:

   execlp ("/usr/bin/csh", "-csh", (char*)NULL);

   Improve the above, if you want to supply more arguments.

Guessing: Perhaps your login scripts are not optimal, so that you feel
the need to always source .login?

You *really* want to use csh(1) instead of tcsh(1)?
Compile tcsh yourself or get a precompiled package.

 > I actually don't know how to find out which version of csh I'm using...

There is no easy way, no real versioning and it doesn't really matter.

Sven
--
[supersede, stupid typo]

 
 
 

How to invoke a login csh?

Post by Fei Che » Sun, 18 Feb 2001 09:00:00


Sven,

Thanks for the help.

I was reading the csh man page and it said to invoke csh with a -, but of
course there was no link so it wasn't working and I didn't know why. But
now I do thanks.

Regarding optimality of .login file: you are probably right. I'm in the
rather awkward situation where I cannot/don't want to change my login
shell (as far as I understand it's an issue due to yellowpage? and
different platforms?), but I only use zsh. My current set up is to put a
line "exec zsh -l" in the .login file, and invoke csh as a login shell so
.login is read and zsh is executed. This is probably far from being
optimal, so if you or the newsgroup have better alternatives I'd love to
hear them.

Thanks much,

Fei



>  > With the version of csh that came with Linux Redhat 6.2 ,
>  > I can do "csh -l"

> Because it actually is a tcsh.

>  > but there's not this option for the csh on the SunOS

> Yes, csh (like ksh) has to be invoked with a dash as first character
> in argv[0], '-csh'.

>  - Either make a soft/hardlink with this name and have the according
>    directory in your PATH as there mustn't be more leading characters.
>    (ksh knows better here, btw)

>  - Or invoke csh as login shell with a c program, the way login(1) does:

>    execlp ("/usr/bin/csh", "-csh", (char*)NULL);

>    Improve the above, if you want to supply more arguments.

> Guessing: Perhaps your login scripts are not optimal, so that you feel
> the need to always source .login?

> You *really* want to use csh(1) instead of tcsh(1)?
> Compile tcsh yourself or get a precompiled package.

>  > I actually don't know how to find out which version of csh I'm using...

> There is no easy way, no real versioning and it doesn't really matter.

> Sven
> --
> [supersede, stupid typo]

 
 
 

How to invoke a login csh?

Post by Sven Maschec » Sun, 18 Feb 2001 10:09:19


 > Regarding optimality of .login file: you are probably right. I'm in the
 > rather awkward situation where I cannot/don't want to change my login
 > shell (as far as I understand it's an issue due to yellowpage? and
 > different platforms?), but I only use zsh.

You should always be able to use /bin/sh as login shell.
(i do so for similar reasons)

At the end of .profile you could test for "$0" being "-sh"
and exec() to another shell.  (Apart from that zsh avoids
~/.profile anyway, when not called in sh or ksh mode).

Translating the csh-syntax stuff into bourne syntax could be
good-exercise - and good-bye to csh.

Sven