shell scripting while loop lab 15 help

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions shell scripting while loop lab 15 help
# 1  
Old 08-02-2011
shell scripting while loop lab 15 help

hi.. this is shell scripting lab15.sh

i dont understand this lab i am at the screen shot part. i was wondering if someone can take a quick look at this lab i have linked the doc below. i dont know where to start

i have did the
Required Errorlevels

Errorlevel # but dont have the last one (19)
i no some error levels are wrong.(
if [ $5 -gt 1 ]).


here is the lab 15 link below it will open online :


https://viewer.zoho.com/docs/k5Uuh --< lab15

this is my lab 14 now i have to add lab 15 into it i now the last part is wrong


# equal to 0
if [ $# -eq 0 ]
then
echo ""
echo "Error: No arguments present at all"
echo ""
echo "Usage: ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo ""

exit 10
fi

#first argument

if [ "$1" != "-i" ]
then
echo ""
echo "Error: Expecting \"i\" for the first argument"
echo ""
echo "Usage: ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> the filename containing the existing data."
echo " -o <outfile> the filename you want the output to go to."
echo
exit 12
fi

#2argument

if [ "$2" = "" ]
then
echo ""
echo "Error: Second argument is missing."
echo "Usage: ./Lab_14.sh -i <infile> -o <outfile>"
echo ""
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo ""
exit 13
fi

#

if [ ! -e $2 ]
then
echo ""
echo "Error: File \"./input.txt\" does not exist."
echo ""
exit 14
fi

#3 argument

if [ "$3" = "" ]
then
echo ""
echo "Error: Third argument missing"
echo ""
echo "Usage: ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo ""

exit 15

fi

#

if [ "$3" != "-o" ]
then
echo ""
echo "Error: Expecting \"-o\" for the third argument."
echo ""
echo "Usage: ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo ""

exit 16
fi

#4 argument

if [ "$4" = "" ]
then
echo ""
echo "Error: Fourth argument missing."
echo ""
echo "Usage: ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo ""

exit 17
fi

#

if [ ! -e $4 ]
then
echo ""
echo "Message: file \"./output.txt\" does not exist already. Creating new file."
echo ""
echo "Correct amount of arguments provided ..."
echo ""
echo "First argument was: -i"
echo "Second argument was: ./input.txt"
echo "Third argument was: -o"
echo "Fourth argument was: ./output.txt"
echo ""
else
echo ""
echo "Message: File \"./output.txt\" exists already. Overwriting content."
echo ""
echo "Correct amount of arguments provided ..."
echo ""
echo "First argument was: -i"
echo "Second argument was: ./input.txt"
echo "Third argument was: -o"
echo "Fourth argument was: ./output.txt"
echo ""

fi

#to many arguments

if [ $# -gt 4 ]
then
echo ""
echo "Error: Too many arguments provided."
echo ""
echo "Usage ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo ""
exit 18
fi

#to many arguments 0 bigger the 0

if [ $5 -gt 1 ]
then
echo "Error: Too many arguments provided."
echo ""
echo "Usage ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo ""
echo "Previous process Errorlevel was: 18"
exit 19
else
echo ""
echo "Message: File \"./output.txt\" exists already. Overwriting contents."
echo ""
echo "Correct amount of arguments provided ..."
echo ""
echo "First argument was: -i"
echo "Second argument was: ./input.txt"
echo "Third argument was: -o"
echo "Fourth argument was: ./output.txt"
exit 19
fi

#end script


Last edited by beerpong1; 08-03-2011 at 12:39 AM..
# 2  
Old 08-03-2011
Please fill out the template as required, and use [CODE] tags when posting your script.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to get the for loop output from a remote server in UNIX shell scripting?

Hi, I am using ksh , when i try to use for loop i am getting the expected output. $for variable in $(ps -fu user | grep -i something/ | grep -i something | grep -v grep | awk '{print $2}');do > grep $variable /tmp/some_path/*/* > done when tried the below to remote server, getting... (4 Replies)
Discussion started by: karthikram
4 Replies

2. Shell Programming and Scripting

If else condition inside for loop of awk command in UNIX shell scripting

Hi , Please excuse me for opening a new thread i am unable to find out the syntax error in my if else condition inside for loop in awk command , my actual aim is to print formatted html td tag when if condition (True) having string as "failed", could anyone please advise what is the right... (2 Replies)
Discussion started by: karthikram
2 Replies

3. Shell Programming and Scripting

How to pass current year and month in FOR LOOP in UNIX shell scripting?

Hi Team, I have created a script and using FOR LOOP like this and it is working fine. for Month in 201212 201301 201302 201303 do echo "Starting the statistics gathering of $Month partitions " done But in my scripts the " Month " variable is hard-coded. Can you please any one... (3 Replies)
Discussion started by: shoan
3 Replies

4. Shell Programming and Scripting

while loop shell scripting help

hi i was wondering if someone can help me with a while loop..i have been looking at this for hours and dont no wut to do.. i have to make a menu style.. to have a beeter understanding i have linked a photo at the bottom... http://www.mypicx.com/uploadimg/772204432_08022011_1.pngand then ... (1 Reply)
Discussion started by: beerpong1
1 Replies

5. Shell Programming and Scripting

Clarification on if loop in Shell scripting

Hi, I'm using Ksh and I'm seeing some of code in my programme as given below. Could you please let me know whats is this meeaing ? (I'm new to this unix) grep "1034" /u/kkk/bin/temp5.lst|cut -c1-2 >/u/kkk/bin/temp6.lst if then echo "" ... (2 Replies)
Discussion started by: shyamu544
2 Replies

6. Programming

Shell Script Lab

In the following Shell Script can anyone help me? What are the total scripts? What are the total binaries? What are the total files? #!/bin/sh GREP="/bin/grep -q" if ; then if ; then for | in ${I}/* ;do file ${I} | ${GREP} "executable" && echo "${I} is a binary" file ${I} |... (1 Reply)
Discussion started by: rktompsett
1 Replies

7. Shell Programming and Scripting

while loop in shell scripting

Hi, I have a doubt in usage of while loop in Shell script as Iam new to this. My requirement is that,I have two different directories containing some files which move files to other folder after parsing is done. In my script i wanted to add a while loop which checks for the count in these two... (5 Replies)
Discussion started by: jyothi_wipro
5 Replies

8. Solaris

Problem in for loop of shell scripting in solaris

Hi below is my script for((i=0;i<=$TOTAL;i++)) do echo "IP's created are $s1.$s2.$s3.$s4" s4=`expr $s4 + 1` done where s1,2,3,4 are input varibles below error occurs while running the script syntax error at lin 11: '(' unexpected ... (12 Replies)
Discussion started by: krevathi1912
12 Replies

9. Shell Programming and Scripting

new to shell scripting: whats wrong with my if loop

#!/bin/bash for file in $HOME/*; do if ; then rm -i $file > /dev/null echo "$?" echo "$file has been deleted" fi done Been trying to learn shell scripting for a week or so now, when i run the script it doesnt display an error message, seems like it runs fine, however it doesnt delete... (10 Replies)
Discussion started by: stride6
10 Replies

10. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies
Login or Register to Ask a Question