- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: how to implement script command in a .cshrc ( ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 06:38 AM
тАО10-31-2007 06:38 AM
how to implement script command in a .cshrc ( csh)
i encounter error when try to implemented a script command in a .cshrc file.
the line i added in .cshrc is :
set tstamp=(`date +%d%m%Y-%H%M%S`)
set fscript=/sgx/core/tslog/log-$tstamp
script $fscript
#echo $tstamp
Is the way doing is wrong for .cshrc ? any help is appreaciate. i canot figure what went wrong.
attached the 1st part of the .cshrc contents and the next part separated by line is the error shown when i login as the particular user .cshrc profile
- Tags:
- csh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 06:46 AM
тАО10-31-2007 06:46 AM
Re: how to implement script command in a .cshrc ( csh)
setenv tstamp `date +%d%m%Y-%H%M%S`
setenv fscript /sgx/core/tslog/log-$tstamp
script $fscript
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 06:54 AM
тАО10-31-2007 06:54 AM
Re: how to implement script command in a .cshrc ( csh)
Did you just log into the system as a regular user when the output was generated? I'm not sure why you get the multiple iterations of the script command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 07:09 AM
тАО10-31-2007 07:09 AM
Re: how to implement script command in a .cshrc ( csh)
csh was used because legacy, then can the user variable assigned using the setenv?
I as a root user, then i do su - user and run the .cshrc and get the script command running repeately. i am wonder why ? also some error
Warning: ridiculously long PATH truncated
any idea ?
i try your method it still don't work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 07:15 AM
тАО10-31-2007 07:15 AM
Re: how to implement script command in a .cshrc ( csh)
PATH keeps getting added to, no logins get finished, and so on.
Still not sure why you'd want to use csh. I'm not sure what you mean by "Its legacy"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 07:21 AM
тАО10-31-2007 07:21 AM
Re: how to implement script command in a .cshrc ( csh)
note that if you do something like this in the other shells, the command immediately after the "script" command needs to be "exit", otherwise the user will remain logged in after they type exit the first time (and logging to the file will be shut off)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 07:38 AM
тАО10-31-2007 07:38 AM
Re: how to implement script command in a .cshrc ( csh)
the script in .cshrc is seems working, but i noted a strange behaviour. When the 3 new added line executed, the alias ( shortcut ) in .cshrc missing when i do a su - user .
later when i type exit command it come back to the csh prompt with alias take effect ?
How to explain on this ? strange.
any advise is appreaciate.
bin is a shorcut to a path /sgx/core/bin
for e.g
$ pwd
/sgx/login/coreadm/RUN
$ bin
sh: bin: Execute permission denied.
$ exit
Script done, file is /sgx/core/tslog/log-01112007-033355
[~/RUN ](21)
[~/RUN ](21) bin
[/sgx/core/bin ](22)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 07:53 AM
тАО10-31-2007 07:53 AM
Re: how to implement script command in a .cshrc ( csh)
-i Force csh to respond interactively when called from a device other than a computer terminal (such as another computer). csh normally responds non-interactively. If csh is called from a computer terminal, it always responds interactively, regardless of which options are selected.
note the part about "runs interactively". this implies that the .cshrc will always be run, so you are basically recursing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 07:55 AM
тАО10-31-2007 07:55 AM
Re: how to implement script command in a .cshrc ( csh)
strange problem is when i su - username run the .cshrc ,
it say :
Script started, file is /sgx/core/tslog/log-01112007-035155
$
normally when user login it should show this type of prompt.
[~/RUN ](21)
BUT the csh prompt suppose to show is gone, and only when i type exit it return back and all alias is back to effect, how to overcome this problem. i try to put a exit after the script command , it show same symptom.
any advise is appreaciate. for e.g
bin is a shorcut to a path /sgx/core/bin
$ pwd
/sgx/login/coreadm/RUN
$ bin
sh: bin: Execute permission denied.
$ exit
Script done, file is /sgx/core/tslog/log-01112007-033355
[~/RUN ](21)
[~/RUN ](21) bin
[/sgx/core/bin ](22)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 08:03 AM
тАО10-31-2007 08:03 AM
Re: how to implement script command in a .cshrc ( csh)
A) I wouldn't / don't expect this to ever work as you want in csh.
B) It will work as desired if you change the users shell to either sh (POSIX) or sh
C) If you do B, then but "exit" after script in the users ".profile"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 08:04 AM
тАО10-31-2007 08:04 AM
Re: how to implement script command in a .cshrc ( csh)
So there is no remedy for this issue ?
cause the .cshrc is run without user input. am i right ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 08:22 AM
тАО10-31-2007 08:22 AM
Re: how to implement script command in a .cshrc ( csh)
I haven't used this shell in ~10 years, so I'm not real sure. This should get you close.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 02:52 PM
тАО10-31-2007 02:52 PM
Re: how to implement script command in a .cshrc ( csh)
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.)
- Tags:
- scummy C shell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 03:22 PM
тАО10-31-2007 03:22 PM
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. it basically same as what i describe early.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 03:33 PM
тАО10-31-2007 03:33 PM
Re: how to implement script command in a .cshrc ( csh)
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 03:38 PM
тАО10-31-2007 03:38 PM
Re: how to implement script command in a .cshrc ( csh)
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 03:47 PM
тАО10-31-2007 03:47 PM
Re: how to implement script command in a .cshrc ( csh)
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 04:06 PM
тАО10-31-2007 04:06 PM
Re: how to implement script command in a .cshrc ( csh)
>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...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 04:26 PM
тАО10-31-2007 04:26 PM
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 04:42 PM
тАО10-31-2007 04:42 PM
Re: how to implement script command in a .cshrc ( csh)
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 05:05 PM
тАО10-31-2007 05:05 PM
Re: how to implement script command in a .cshrc ( csh)
i try the method put the "exec $fscript " at last line in .login, the .cshrc environment variable is source,
But i want to change the file ownership created by the script to root user so the user would not able to edit the file, but i insert the line :
/usr/bin/chown root:sys $fscript, and after i check the files ownership is not modified to be owned by root users, mayb once it something to do with "exec " behaviour ? anyway to overcome this, if i put the chown line before the script it will complain the file not found cause files haven;t created. Right.
source /sgx/login/super1/.cshrc
setenv tstamp `date +%d%m%Y-%H%M%S`
setenv fscript /sgx/core/tslog/log-$tstamp
exec script $fscript
/usr/bin/chown root:sys $fscript
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 05:53 PM
тАО10-31-2007 05:53 PM
Re: how to implement script command in a .cshrc ( csh)
I assume this means everything else works? If so great!
>but i insert the line:
/usr/bin/chown root:sys $fscript, and after i check the files ownership is not modified to be owned by root users, maybe once it something to do with "exec" behaviour?
Where did you insert that line? (Ah after)
>if i put the chown line before the script it will complain the file not found cause files haven't created.
source /sgx/login/super1/.cshrc
setenv tstamp `date +%d%m%Y-%H%M%S`
setenv fscript /sgx/core/tslog/log-$tstamp
exec script $fscript
/usr/bin/chown root:sys $fscript
Hopefully another "simple solution". :-)
You can't have that line after exec since it does NOT return.
You can put it before:
touch $fscript
/usr/bin/chown root:sys $fscript
exec script $fscript
I assume you have changed or have the permissions so this user can write to it?
This is contradictory with your request:
>But i want to change the file ownership created by the script to root user so the user would not able to edit the file,
So the only way to do that is to redirect stdin to a file. And when you invoke script you need to redirect stdin to /dev/tty.
Forget that. Remove the eval and just do:
script $fscript
/usr/bin/chown root:sys $fscript
exit
I think script will read from stdin until "exit".
Then it will come back to the chown and exit.
Control C seems to be handled by script and won't be broken out of your jail. The only problem is the user can write junk to $fscript.
The only solution is to make $fscript a named pipe. At least he can't overwrite the beginning.
The pipe would have to have a root logger to continuously read from it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 07:15 PM
тАО10-31-2007 07:15 PM
Re: how to implement script command in a .cshrc ( csh)
you are right .
If the user smart enough, before the file ownership change to root owner, they will modified the script file within the session before typing exit command, cause the chown only executed at the end of the " script " command exit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-01-2007 12:41 AM
тАО11-01-2007 12:41 AM
Re: how to implement script command in a .cshrc ( csh)
This topic (using script command during login) have been discussed several times before...
See f.ex.
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1163248
It ain't a good idea, and you might create some workarounds.
Perhaps you could rather limit what the user is allowed to do (like with sudo)?
/2r
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-05-2007 03:43 AM
тАО11-05-2007 03:43 AM