[SunHELP] Sun Script
Vishal
vishal at netsolutionsindia.net
Wed Apr 28 15:07:19 CDT 2004
Hello ,
Thank you for the reply, this is how i modify the script but it gives me
error message :
shell: line 17: syntax error near unexpected token `'o')'
shell: line 17: `'o')'
Any Comments ?
===================================
#!/bin/sh
loop=1
while $loop;
do
echo -n "Enter d [to List files], o <name> [check the file], s <name> [make
the directory] or 6 to quit:"
read input
case $input in
'd')
ls -l
'o')
read name
cat $name
's')
read dir1
mkdir $dir1
cd $dir1
'6')
echo "Exiting..."
unset $loop
'*')
echo "Invalid Command you jerk!"
esac
done
----- Original Message -----
From: "Dale Ghent" <daleg at elemental.org>
To: "Vishal" <vishal at netsolutionsindia.net>; "The SunHELP List"
<sunhelp at sunhelp.org>
Sent: Thursday, April 29, 2004 1:14 AM
Subject: Re: [SunHELP] Sun Script
> On Apr 28, 2004, at 2:49 PM, Vishal wrote:
>
> > Hello All,
> >
> > I would like to have the follwing script :
> >
> > Write a UNIX shell script that will prompt the user with information to
> > enter the
> > Letter "d", "o" or "s" to execute the command as follows:
> > d - to list the contents of directory in long format.
> > o - <name> to check if a file <name> is in the current directory and
> > displays if it is present or not
> > s - <name> to make a new directory called <name> and change to a the
> > new
> > directory <name>
> > If an input other than "d", "o" or "s" is provided, display the
> > message "no!
> > try again". Put your code in a loop, so that the shell script is
> > terminated
> > by inputting the number 6.
> >
> > if somebody can help me to write this.
>
> This is so simple. Specifically, you are looking for the read, case,
> while and for commands in Bourne shell (sh, bash)
>
> Example:
>
> #!/bin/sh
>
> loop=1
>
> while $loop;
> do
>
> echo -n "Enter your command or 6 to quit:"
> read input
>
> case $input in
>
> 'd')
> dostuff
>
> 'o')
> domorestuff
>
> 's')
> dootherstuff
>
> '6')
> echo "Exiting..."
> unset $loop
>
> '*')
> echo "Invalid Command you jerk!"
> esac
>
> done
>
More information about the SunHELP
mailing list