Solved

C shell

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem logging tar errors 11 74
Linux "time" command output redirection 16 260
Install MySQL 5.6 and PHP on Centos Linux 6 180
Shell Script on AIX 7 177
When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
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.
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.

739 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