Solved

C shell

Posted on 2001-06-15
5
216 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 50 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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 …
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Suggested Courses

615 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