Computing.Net > Forums > Unix > question for all

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

question for all

Reply to Message Icon

Name: mona
Date: March 28, 2006 at 08:49:28 Pacific
OS: windows xp
CPU/Ram: pentum m
Product: dell 600
Comment:

could any one of u help me in solving this problem

*********please the deadline is tomorrow*******

Write a shell script (give it the name: skinny) which receives any number of arguments. Those arguments are in fact themselves Unix commands (e.g. cat, cp, mv, clear, ls,...).
Once invoked, it shall display a prompt like this:
Skinny Shell>
And shall only allow the user to execute the Unix commands received as arguments. If a command which is not among those arguments is entered, it should be ignored and an error message shall be printed on the screen. If the command is among the list of arguments, then it shall be executed. In all cases the above prompt shall be always echoed.
To exit, we shall just type: quit

thanx



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: March 28, 2006 at 09:06:25 Pacific
Reply:

I shouldn't do this, but here's the hard part - the loop. I'll leave it to you to make the comparison:

#!/bin/ksh

echo "your prompt"
read command
cnt=0
for i in $*
do
if [[ $i = $command ]]
then
cnt=1
break
fi
done
echo $cnt


0

Response Number 2
Name: mona
Date: March 28, 2006 at 09:30:02 Pacific
Reply:

thanks for ur help


please solve cause i still have two problems and i am working with them now and its 9:30 pm and there is no time
pleeeeeeeeeeeeeeeeeeeeeese


0

Response Number 3
Name: mona
Date: March 28, 2006 at 09:34:27 Pacific
Reply:

i didnt understand (cnt)
what do u mean ??


0

Response Number 4
Name: mona
Date: March 28, 2006 at 10:27:32 Pacific
Reply:

i couldnt do more than this

please help me

echo -n " Skinny Shell>"

a= `line`

for i in $*
do

if [ $i = a ]
then

./exec.txt a

break

elif [ a = " quit " ]
then

kill (i dont know what i have to put here)

else

echo "not available"

f
i


done



0

Response Number 5
Name: nails
Date: March 28, 2006 at 13:15:56 Pacific
Reply:

Your requirements are not very clear.

#!/bin/ksh

while true
do
printf "Skinny Shell > "
read command
if [ "$command" = "quit" ]
then
break
fi

cnt=0
for i in $*
do
if [[ $i = $command ]]
then
cnt=1
break
fi
done
if [ $cnt -eq 1 ]
then # execute the command if valid unix
printf "Executing valid command\n"
eval $*
else
printf "Invalid command\n"
fi
don


0

Related Posts

See More



Response Number 6
Name: lisa
Date: March 28, 2006 at 14:01:46 Pacific
Reply:

Here is a sample output from my skinny shell script:
mona@amazon:~/spring2006/os470> skinny date pwd ls cal
Skinny Shell> ls
a1q1 execCommand getFirst lab1 lab2 skinny
Skinny Shell> cal 3 2006
March 2006
S M Tu W Th F S
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Skinny Shell> date
Wed Mar 8 16:33:31 GST 2006
Skinny Shell> pwd
/staff/mona/spring2006/os470
Skinny Shell> cat skinny
Command not available!
Skinny Shell> clear
Command not available!
Skinny Shell> bye
Command not available!
Skinny Shell> quit
mona@amazon:~/spring2006/os470>
In the above execution, I only restricted the shell to the commands: date, pwd, ls and cal. Any other Unix –or non Unix- command will not be accepted


0

Response Number 7
Name: mona
Date: March 29, 2006 at 06:25:46 Pacific
Reply:

hi Nails

it is work

thank you very much


0

Response Number 8
Name: nivruttisk
Date: April 2, 2006 at 07:30:04 Pacific
Reply:

Hi!
I have installed sco unix 3.2v4.2 on Team Server (EISA - configuration M/C), I tried to add another scsi hdd, but it coutldn,t add properly and then my present os installation also get damage so reinstalled os. Pls. tell me proper method to do such old stuff.

Regards,
Nivrutti.
(Email - nivruttisk@accelfrontline.in / nskesarkar@yahoo.com)


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: question for all

No UNIX/Linux with CIS degree?? www.computing.net/answers/unix/no-unixlinux-with-cis-degree/3321.html

Newbie setup/configuration questions for RedHat 5.2 www.computing.net/answers/unix/newbie-setupconfiguration-questions-for-redhat-52/297.html

unix question www.computing.net/answers/unix/unix-question/592.html