shell script programming issues


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers shell script programming issues
# 1  
Old 12-01-2008
shell script programming issues

I'm having trouble running this script. I'm new to Unix so be kind please.

#!/bin/sh

# Test to make sure only a single parameter is passed from the
# command line.
if [ "$#" -ne "1" ]
then
echo "Usage: AC.sh <directory>"
exit
fi

# Is the parameter a directory test
if [ ! -d $1 ]
then
echo "This is a directory."
else
echo "$1: No such directory."
exit
fi

if [ $? -eq 0 ]
then
echo $1 " is a directory."
elif [ $? -gt 0 ]
then
echo $1 " is not a directory."
fi

Last edited by FSUdude08; 12-01-2008 at 02:43 AM..
# 2  
Old 12-01-2008
The script working but, I'm not sure if the result is the same as you want to reach?
# 3  
Old 12-01-2008
No need to have the quotes in "$#" -ne "1"
if [ ! -d $1 ] here to have the quotes...for $1...

Kindly let me know what is the error u r getting...so that it will be easier to solve...
# 4  
Old 12-01-2008
I'm sorry, I was copying code from my teacher's sample solution and I noticed he had more than what I pasted. Thanks for the help anyway. I'll be needing some more in the near future since exams are in 2 weeks. Thanks again.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Facing issues with shell script changes

My current requirement is to replace xxyxx string with value of date date1 variable holds a date and the current script writes html tags to a file as follows echo date1 nawk 'BEGIN{ FS="," print "<HTML>""<HEAD>""<p>Hi All,<br><br>There are no cases closed on the xxyxx" print ... (2 Replies)
Discussion started by: Rajesh A S
2 Replies

2. UNIX for Dummies Questions & Answers

Shell script to read lines in a text file and filter user data Shell Programming and Scripting

sxsaaas (3 Replies)
Discussion started by: VikrantD
3 Replies

3. Shell Programming and Scripting

Convert my shell script to C programming HELP!!

I had try to create a basic shell script. So now im trying to convert in to C-programming language can some one guide/help me out with it?(BTW IM USING A LINUX/UNIX/ORACLE SYSTEM) CODE BELOW !/bin/bash for i in `ls -1 /cslab/home/JAZEL/` do cp -uv $i /cslab/home/JAZEL/cs295/$i.`date... (2 Replies)
Discussion started by: Nygenesis
2 Replies

4. Shell Programming and Scripting

Shell Script execution issues

Hi, There's a shell script by name "download", which has been created as user "mgr" and that script needs to executed as user "dev". I tried giving privileges 701 on the script download. But it's throwing the error message bin]$ ./download /bin/bash: ./download: Permission denied ... (6 Replies)
Discussion started by: venkatesh17
6 Replies

5. Shell Programming and Scripting

Shell Script migration issues

Hi All, We will be doing a Solaris 8 to Solaris 10 migration migration, just wanted to know if there are any known / common issues arise from this migration from Shell script point of view. I tried searching this site but mostly post are related to SA's question and jumpstart, etc. If there's... (4 Replies)
Discussion started by: arvindcgi
4 Replies

6. Shell Programming and Scripting

Shell script programming help

I'm new to this and I need help with writing a script. The following assignment is as follows... Create a shell script named Project3-8 located in a directory supported by the File System Hierarchy Standard. The script needs to perform the following pseudocode in the order shown: -Display... (1 Reply)
Discussion started by: sdpinoy
1 Replies

7. Shell Programming and Scripting

Calender Unix programming date issues

Hi, i;m beginner of Unix, i trying to use crontab to zip my log file automatically, below is my coding, some of the statement i don't know whether is correct or not. Pls help:) year=`date '+%Y'` month=`date '+%m'` day=`date '+%d'` day=`expr $day - 1` case $month in 1 | 3 | 5 | 7 | 8 | 9 |... (4 Replies)
Discussion started by: dannyd_y
4 Replies

8. Shell Programming and Scripting

Need help : Shell Script Programming

I have to complete my assignment and i need help... These are two simple shell script programs : 1.) Write a shell script to display files in the current directory in the following format : FileName Size Date Protection Owner _______ ____ ___ ________ _____ 2.) Write a... (1 Reply)
Discussion started by: harshthegreat89
1 Replies

9. Shell Programming and Scripting

shell script performance issues --Urgent

I need help in awk please help immediatly. This below function is taking lot of time Please help me to fine tune it so that it runs faster. The file count is around 3million records # Process Body processbody() { #set -x while read line do ... (18 Replies)
Discussion started by: icefish
18 Replies

10. Shell Programming and Scripting

Shell Script Programming

The problem is to : develop a shell script which allow patty and mick( two login names) to execute a program (3 Replies)
Discussion started by: abhishek0216
3 Replies
Login or Register to Ask a Question