- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: C-shell and terminal attachment check
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
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
тАО08-21-2005 11:01 PM
тАО08-21-2005 11:01 PM
I have a problem with C-shell...
The problem is this single line in the .login file of the c-shell user тАЭsap1тАЭ:
eval `tset -s -Q -m ':?hp' `
which causes commands like the following:
su тАУ sap1 -c "whatever start"
to prompt for a terminal
.... unpractical for crontab execution!
I am aware that expect or line deletion could solve the problem. But I would prefer something in the .login file of sap1 which would check whether a terminal was connected, i.e. c-shell functionality corresponding to "if [[ -t 0 ]]" of the Bourne-shell.
However, I cannot find anything like that. Can anybody help?
regards,
John K.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-21-2005 11:24 PM
тАО08-21-2005 11:24 PM
Re: C-shell and terminal attachment check
% test -t 0 && echo ok
Or else you can check with who command output to check terminal connectivity.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-21-2005 11:26 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-21-2005 11:40 PM
тАО08-21-2005 11:40 PM
Re: C-shell and terminal attachment check
if ( $?prompt ) then
...
endif
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2005 01:13 AM
тАО08-22-2005 01:13 AM
Re: C-shell and terminal attachment check
Muthukumar,
I have tried with this constructuion in sap1's .login:
test -t 0 && eval `tset -s -Q -m ':?hp' `
which apparently works when activated from cron in a Bourne_shell script containing a line like this:
su - sap1 -c "system start"
and the very same Bourne-shell script prompts for a terminal in interactive mode.
Ermin,
can you please elaborate a little on your response? Does it mean that if the prompt has not already been set, then you enter the if-sentence?
Points will be assigned later!
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2005 01:34 AM
тАО08-22-2005 01:34 AM
Re: C-shell and terminal attachment check
if tty -s
then
INTERACTIVE=/sbin/true
else
INTERACTIVE=/sbin/false
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2005 12:36 PM
тАО08-22-2005 12:36 PM
Re: C-shell and terminal attachment check
if ( $?prompt ) then
eval `tset -s -Q -m ':?hp'`
endif
Therefore tset will be run for interactive shells only. Shells run from crontab are not interactive so section enclosed by if statement will be ignored.
However, in your case when shell script is run from command line tset will run because shell is interactive.
If you don't want to get asked for terminal type try using
if ( $?prompt ) then
eval `tset -s -Q`
endif
If you include ':?hp' part, then tset always asks for terminal type and defaults to terminal type 'hp'.
Alternative to tset is ttytype command which is used to identify terminal type.
eval `ttytype -s`
will automatically detect and set the terminal type.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2005 01:24 PM
тАО08-22-2005 01:24 PM
Re: C-shell and terminal attachment check
tput ttytype tabs stty
And while you're at it, I would also skip login messages such as /etc/copyright, /etc/motd, and checks like news and mail. This reduces the junk in email from cron or logs.
Bill Hassell, sysadmin
- Tags:
- stty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2005 11:50 PM
тАО08-22-2005 11:50 PM
Re: C-shell and terminal attachment check
I have tried a variety of combinations in .login:
A:
test -t 0 && eval `tset -s -Q -m ':?hp'
Prompts for terminal in interactive mode.
Does not hang when executed from crontab.
Does not produce error messages when executed from crontab.
B:
if ( $?prompt ) then
eval `tset -s -Q -m ':?hp'`
stty erase "^H" kill "^U" intr "^C" eof "^D" susp "^Z" hupcl ixon ixoff tostop tabs
endif
Prompts for terminal in interactive mode.
Does not hang when executed from crontab although it enters the if-sentence (?!), which produces the normal error messages from tset and stty. (not quite what I had expected, but perhaps I have not used it correctly).
C:
setenv INTERACTIVE no
test -t 0 && setenv INTERACTIVE yes
if ( "${INTERACTIVE}" == "yes" ) then
eval `tset -s -Q -m ':?hp'`
stty erase "^H" kill "^U" intr "^C" eof "^D" susp "^Z" hupcl ixon ixoff tostop tabs
endif
Prompts for terminal in interactive mode.
Does not hang when executed from crontab.
Does not produce error messages when executed from cron.
Thank you for your responses; as you can see, they were all useful.
- and thanks for mentioning the "news" command, whose existance I had till now completely ignored!
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2005 11:53 PM
тАО08-22-2005 11:53 PM