Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

C shell

Posted on 2001-06-15
5
Medium Priority
?
218 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 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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…

722 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