Solved

C shell

Posted on 2001-06-15
5
210 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 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 20

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Using Grep to Find a file 8 73
AIX 5.x set up arrow to recall 11 42
Linux: disable vim auto-comment 7 64
UNIX SCP 5 48
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 …
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now