1843979 Members
1787 Online
110226 Solutions
New Discussion

Re: Script

 
M.sureshkumar
Regular Advisor

Script

Hi Guys,

I am giving my original script.
Script:

echo
echo ' \c'
tput smso
echo 'WARNING: Training Database ? '
tput rmso
echo ' Are U Sure [Y/N]: \c'
read reply
/data/xxxx/xxxxx/xxxxx
;;

In the above script,suppose i choose either yes or no then it will go to training database.

Pls modify the script for the below options,

Yes --> /data/xxxx/xxxxx/xxxxx
No ----> /usr/bin/xxxx

Regards,
M.Suresh

18 REPLIES 18
A. Clay Stephenson
Acclaimed Contributor

Re: Script

read reply
case "${reply}" in
y|Y) /data/xxxx/xxxxx/xxxxx
;;
n|N) /usr/bin/xxxx
;;
*) echo "Bad Response;
;;
esac
If it ain't broke, I can fix that.
M.sureshkumar
Regular Advisor

Re: Script

hi,

After modified the script, i got the following error.

Error:

script interpreter "/bin/sh" not found
script interpreter link resolves to "/usr/bin/sh"
/usr/bin/mfgmenu[34]: mfgdems: not found.

Pls guide to me .

Thanks.

Bharat Katkar
Honored Contributor

Re: Script

the same is also possible using if then else:

read reply
if [ "$reply" = "Y" -o "reply" = "y" ]
then
/data/xxxx/xxxxx/xxxxx
elif [ "$reply" = "N" -o "reply" = "n" ]
then
usr/bin/xxxx
else
echo " bad option "
fi






You need to know a lot to actually know how little you know
Bharat Katkar
Honored Contributor

Re: Script

At the begining of the script you have to specify the Shell which you are going to use and ensure that the related binaries are present at there respective location.
for e.g.
#!/usr/bin/sh



You need to know a lot to actually know how little you know
KapilRaj
Honored Contributor

Re: Script

Can u attach ur script please

Regds,

Kaps
Nothing is impossible
KapilRaj
Honored Contributor

Re: Script

Use

#!/usr/bin/sh

Also Confirm your executable is present

In /usr/bin/mfgmenu script on 30th line see whether you have a path exported for mfgdems executable / script

Regds,

Kaps
Nothing is impossible
Sanjay Kumar Suri
Honored Contributor

Re: Script

Check this

#!/usr/bin/sh
echo
echo ' \c'
tput smso
echo 'WARNING: Training Database ? '
tput rmso
echo ' Are U Sure [Y/N]: \c'
read reply
if [ $reply = "y" -o $reply = "Y" ]
then
echo "Yes"
/data/xxxx/xxxxx/xxxxx
elif [ $reply = "n" -o $reply = "N" ]
then
echo "No"
/usr/bin/xxxx
else echo "Invalid"
fi

sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
Mark Grant
Honored Contributor

Re: Script

I'd do it this way

#!/usr/bin/sh

TARGET=/data/xxxx/xxxxx/xxxxx
echo
echo ' \c'
tput smso
echo 'WARNING: Training Database ? '
tput rmso
echo ' Are U Sure [Y/N]: \c'
read reply
[[ $reply == "y" -o $reply == "Y" ]] && TARGET=/usr/bin/xxxx

$TARGET
Never preceed any demonstration with anything more predictive than "watch this"
Mark Grant
Honored Contributor

Re: Script

Apologies, I just got in and already my brain is failing. Scrap that last one. Doesn't work too well if there is user input involved.
Never preceed any demonstration with anything more predictive than "watch this"
M.sureshkumar
Regular Advisor

Re: Script

Hi Guys,

I Have attached my full script.

Pls modify the script in 3rd switch for the below options,

Yes --> /data/xxxx/xxxxx/xxxxx
No ----> /usr/bin/xxxx

Thanks,

M.Suresh.

Bharat Katkar
Honored Contributor

Re: Script

Go thr' attached script.
You need to know a lot to actually know how little you know
KapilRaj
Honored Contributor

Re: Script

I have assigned points to 5 of 87 responses to my questions.

Can u go through this following link please I think u r new here.

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=140137

Kaps
Nothing is impossible
Santosh_16
Visitor

Re: Script

Hi Suresh,

Attaching the modified script

Regards,
Santosh
M.sureshkumar
Regular Advisor

Re: Script

Hi Guys,

I am sending the same script,pls modify the below options,

Yes ---> /data/xxxx/xxxxx
No ----> 0) exit i.e last switch in my script

Pls modify this script.


Thanks,
Suresh.
KapilRaj
Honored Contributor

Re: Script

Suresh,

It will always be better not to depend on other's but take their advise and action ur selves....

Your script is a very simple shell script. Let's see what it does ..

Check what is read in "x" variable
if x is

1). Execute /xxx/xxxclst
2). Execute /xxx/xxxclst
3). Read another variable and check it is "y" or "N" and if

Y). Execute /xxxx/xxxx/xxxx/
N). Exit
4). Execute /xx/xx/xxx
5). Execute passwd
6). Execute exit

To achieve what u need in 3'rd condition,

You have to add the following lines just after
echo ' Are U Sure [Y/N]: \c'
read REPLY
case $REPLY in
Y) /xxxx/xxxx/xxxx/ ;;
N) exit 8 ;;
esac
;;
4) .... Continue with the same script

Regds,

Kaps

Note : People spend lots of time on ur requests did u get a chance to look at the URL on my last query and assign some rewards ?.
Nothing is impossible
Bharat Katkar
Honored Contributor

Re: Script

Suresh ,
Kapil is right.
I think u need to take look at two aspects.
Your Action / Rewards.
I my self feel very pleasing if anybody helps me when i am in problem.

Bharat

** Go thr' the link suggested

You need to know a lot to actually know how little you know
M.sureshkumar
Regular Advisor

Re: Script

Hi Guys,

Thanks, I findout that problem, the problem was syntex problem.Now it's working fine.

thanks,
Suresh
KapilRaj
Honored Contributor

Re: Script

Suresh,

I can not believe that ur script worked and it was just a syntax problem ! Your script needs correction from my view it is missing a case /if loop which I have pointed out.

Kaps

Nothing is impossible