C Shell Scripting - HELP! - checking total args in a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting C Shell Scripting - HELP! - checking total args in a script
# 1  
Old 12-17-2008
C Shell Scripting - HELP! - checking total args in a script

Hi, I 'm trying to learn the scripting language and am trying to create a script to open a C Program, allow the user to edit it, and then run it. What I have works but only when you enter the name to be compiled and the c program, but what if you only entered the 1 argument (cprogram.c) ? but I 'm trying to error check and got the problem if the user did not put 2 arguments in......the following is what I have :

#!/bin/csh

if ( ! -e $2 ) then
echo 'Error, the file does not exist..'
exit
else if ( ! -e $1 ) then
echo 'Error Please enter the file name to be compiled'
else if ( -e $2 ) then
gedit $2
gcc -o £1 $2
./$1
endif

Any experienced writers can help please?
Thank YouSmilie
# 2  
Old 12-17-2008
Quote:
Originally Posted by patel_ankz
Hi, I 'm trying to learn the scripting language

Do yourself a favour and learn a standard scripting shell. Csh is not recommended for anything more than trivial scripts. See these articles:

Top Ten Reasons not to use the C shell
C shell problems
Csh Programming Considered Harmful
# 3  
Old 12-17-2008
Can anyone try to help me with this as it is still part of my coursework. Sorry I didn't mention it.
# 4  
Old 12-17-2008
Homework postings are a against the rules
Thread closed.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

UNIX Shell Scripting (Solaris) for File Checking

Hi guys, I'm sorry but i badly need your help. I am assigned to do a basic shell script in my job but sadly i don't have any idea on what it is because i am an electronics engineer, but i googled all of it, ask my friends but i cant finalize my scripts. so do please help me. The requirement... (47 Replies)
Discussion started by: daveaztig14
47 Replies

2. Shell Programming and Scripting

Help me with C-shell Script: Disk checking

Hi, i am new in shell script. i have given a task to make a C-shell script. I have list of ip address and device name respectively. For example; cal 1 : 100.21.25.10 cal 2 : 100.21.25.11 cal 3 : 100.21.25.12 cal 4 : 100.21.25.14 and so on... Right now, i have this. #! /bin/csh -f ... (0 Replies)
Discussion started by: lattey
0 Replies

3. Shell Programming and Scripting

Service checking through shell script

I want to check the postgres service for client PC which is remotely placed through shell script , whether the Postgres service is working or not.I don't have an idea to develop this script.Please give me a code. Client PC IP Address: 10.66.1.133 (2 Replies)
Discussion started by: kannansoft1985
2 Replies

4. Shell Programming and Scripting

Dsh command - shell script - sys args?

Sorry, a noobie question....! I want to use a linux cluster to copy a list of files. I want to split the processing over 3 nodes so that each node gets (more or less) an equal share. My script (base.sh) to execute my copy script (copy.sh) looks something like: #!/bin/bash for NODE in 1 2... (4 Replies)
Discussion started by: pc2001
4 Replies

5. Shell Programming and Scripting

Script as login shell (passing args to login shell)

Hello all, for security reasons my compagny imposes that my script be launch remotly via ssh under the users login shell. So serverA launches the ssh command to serverB which has a local user with my script as a login shell. Local script works like a charm on his own. serverB$ grep... (20 Replies)
Discussion started by: maverick72
20 Replies

6. Shell Programming and Scripting

Shell Script for continuously checking status of a another script running in background, and immedia

Hi, I want to write a script which continuously checking status of a script running in background by nohup command. And if same script is not running then immediately start the script...please help.. i am using below command to run script nohup system_traps.sh & but in some... (9 Replies)
Discussion started by: ketanraut
9 Replies

7. Shell Programming and Scripting

Store args passed in array but not the first 2 args

Store args passed in array but not the first 2 args. # bash declare -a arr=("$@") s=$(IFS=, eval 'echo "${arr}"') echo "$s" output: sh array.sh 1 2 3 4 5 6 1,2,3,4,5,6 Desired output: sh array.sh 1 2 3 4 5 6 3,4,5,6 (2 Replies)
Discussion started by: iaav
2 Replies

8. Shell Programming and Scripting

Checking the total size of all files from a particular date

Hi I have some set of files for a particular date. What is the command that I need to put in for finding the total size of all the files for that particular date. The following command is fetching me the size of all individual files seperately du -h *20101010* 16M file1.20101010 120K... (10 Replies)
Discussion started by: bobby1015
10 Replies

9. Shell Programming and Scripting

Regularly checking with shell script

Hi, I am new in scripting and also in Linux. I wrote my first script recently. I have an external hdd connected to my debian machine. I am spinning it down using a spindown code (code.google.com/p/spindown/)when I am not using it ( automatically after 1 hour). The problem was I wanted to know when... (2 Replies)
Discussion started by: aspedisca
2 Replies

10. Shell Programming and Scripting

Checking Files with a Shell Script

Hey everyone, I'm writing a shell script that needs to loop thru a directory and check a defined type of files(.df). I use "checkfile.x" which is a compiled program to check those files. Sintaxis : checkfile.x DatefileName.df The program displays something like this: File: kanswer.df -... (1 Reply)
Discussion started by: Testing_Yorsh
1 Replies
Login or Register to Ask a Question