Operating System - HP-UX
1752736 Members
5495 Online
108789 Solutions
New Discussion юеВ

Re: how to implement script command in a .cshrc ( csh)

 
sstan
Frequent Advisor

Re: how to implement script command in a .cshrc ( csh)

hi Oldschool,
So there is no remedy for this issue ?

cause the .cshrc is run without user input. am i right ?
OldSchool
Honored Contributor

Re: how to implement script command in a .cshrc ( csh)

you might try placing your 3 lines of code in .login file in the user's home directory and see what happens.

I haven't used this shell in ~10 years, so I'm not real sure. This should get you close.
Dennis Handly
Acclaimed Contributor

Re: how to implement script command in a .cshrc ( csh)

>OldSchool: you might try placing your 3 lines of code in .login file in the user's home directory and see what happens.

This seems correct. If you insist on using the scummy C shell you need to know what each file does. .login is similar to .profile and .cshrc is similar to .kshrc (or whatever is in ENV).

I assume Avalanche wants to log the user's commands on login, not for every shell invocation.

>Patrick: Why anyone would willingly use the C shell is a mystery to me.

Exactly.

setenv tstamp `date +%d%m%Y-%H%M%S`
setenv fscript /sgx/core/tslog/log-$tstamp

Why would you suggest exporting those local variables? The only reasonable use is to stop the recursion by checking if tstamp exists. (You didn't suggest that.)
sstan
Frequent Advisor

Re: how to implement script command in a .cshrc ( csh)

HI Oldschool,

I had try to put the 3 lines in the .login of the user home directory, but result the same , it run the script command, the .cshrc export alias is back to normal when i type exit from the script. it basically same as what i describe early.

Dennis Handly
Acclaimed Contributor

Re: how to implement script command in a .cshrc ( csh)

>I had try to put the 3 lines in the .login of the user home directory, but result the same, it run the script command, the .cshrc export alias is back to normal when i type exit from the script.

What .cshrc export alias? You modified .login and you shouldn't have changed anything else.

And you will have to type "exit" twice. Once to exit script(1) and once to exit your scummy C shell. I suppose you can prevent that by using "exec script $fscript".

>it basically same as what i describe early.

You shouldn't have the recursion. Or PATH being too long.
sstan
Frequent Advisor

Re: how to implement script command in a .cshrc ( csh)

Hi Dennis,
Is there any way to overcome this problem? i want to achieve to logged the user login session into a file by doing the script command in csh , but it seems to be problem.

Had try to insert the script line in .login but it doesn't work, the .cshrc alias setting is lost when in invoke the script command, only when exit, the .cshrc alias setting is return normal, and once again i type exit to logout frm the session.

thanks.
Dennis Handly
Acclaimed Contributor

Re: how to implement script command in a .cshrc ( csh)

>the .cshrc alias setting is lost when in invoke the script command,

Ah, simple solution, source .cshrc in .login.

>once again i type exit to logout from the session.

Simple solution exec script(1) as I mentioned.
sstan
Frequent Advisor

Re: how to implement script command in a .cshrc ( csh)

hi Dennis,
>What .cshrc export alias? You modified .login and you shouldn't have changed anything else.
---> .cshrc export the alias of shortcuts to directory, like
alias bin "cd /abc/df/bin"
alias run "cd /abc/login/bh/RUN"
So you mean i only need to put the 3 line in .login or .cshrc ? i try put in .login it doesn;t work, the script kept recursively output the filename with diff timestamp.

>And you will have to type "exit" twice. Once to exit script(1) and once to exit your scummy C shell. I suppose you can prevent that by using "exec script $fscript".
--> so it mean i insert the line "exec script $fscript" in .login or .cshrc file.


>it basically same as what i describe early.
You shouldn't have the recursion. Or PATH being too long.
-----> when i put the 3 line in .cshrc it output the following in attached text file, same error :
Warning: ridiculously long PATH truncated
then cause many file with diff timestamp created, so i need to exit many time to get out from the shell prompt...
sstan
Frequent Advisor

Re: how to implement script command in a .cshrc ( csh)

hi dennis,
i put the line source /sgx/login/super1/.cshrc in .login file, then put the line "exec script $fscript" in .cshrc file.

But it output the same undesired result.
Any advise ?

a file atached with .login follow by .cshrc and a output of the action when i su - user as root and when it run the .cshrc once login.

thanks.
Dennis Handly
Acclaimed Contributor

Re: how to implement script command in a .cshrc ( csh)

>i put the line source /sgx/login/super1/.cshrc in .login file, then put the line "exec script $fscript" in .cshrc file.

Don't touch the .cshrc file. That's no end of problems.

Only change the end of .login to source the .cshrc file, followed by the the set commands, then at the end:
exec script $fscript