Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

C shell

Posted on 2001-06-15
5
Medium Priority
?
220 Views
Last Modified: 2010-04-21
Greetings,

I'm looking for an equivalent to $- in ksh to something in CSH, which shows if its interactive or not.

$?prompt  is a similar functionality..but it works in both cmd line and in a script. ..this is so that certain actions can be taken when run from a script, such as the stty cmd. Because stty complains whe it's run from a non-interactive setting.

Anybody ?
0
Comment
Question by:venkatsr
5 Comments
 
LVL 6

Expert Comment

by:Talmash
ID: 6222690
hi ,

have you heard about $argv[1] , $argv[2] etc ...

it's not so clear in your qustion , but I assume that was
your wish .

in a c-sh script , you can use the argumentS given by the script your with : $argv[i] , i= num of argument

$#argv = returns the number of arguments supplied .

Tal
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 200 total points
ID: 6241210
oops, this is one of the dark sides of csh, 'cause it often OS-dependent :-(
A simple check if interactive or not is using the status returned by the tty (not stty) command, which is 0 or 1.
Some implementations of csh support to query the $arg[0] variable, which is empty or "-" for none-interactive shells (like in rsh, at, cron)
My experiance showed that $#argv is not liable, 'cause its either undefined or set even if the script is sourced (with arguments, which makes no sense):
0
 
LVL 9

Expert Comment

by:PeterMac
ID: 6413607
Venkastr

     You can try testing for "TERM" and "TTY" being set, if neither is set then shell is unlikely to be running from a terminal. Not conclusive but has advantage it works over all Unix versions and all shells.
0
 
LVL 21

Expert Comment

by:tfewster
ID: 7621352
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
- Answered by ahoffmann

Please leave any comments here before 13/1/2003

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

tfewster (I don't work here, I'm just an Expert :-)
0
 

Expert Comment

by:SpideyMod
ID: 7805219
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses
Course of the Month7 days, 22 hours left to enroll

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question