Link to home
Start Free TrialLog in
Avatar of plate55
plate55

asked on

Write a simple shell script

I need help writing a simple shell script that solicits a (Y)es or (N)o response from the user. If the response is 'Y' display a message on the screen that thanks the user for the positive response. If the response is 'N' display a message that thanks the user for the negative response. If the answer is anything else, redisplay the question.
Avatar of Luxana
Luxana
Flag of Australia image

Hi

you can try something like this:
first do
# which perl
and then just change first line of cript according you output

---------------------------------------
#!/usr/bin/perl

while ($input ne 'y'){
print "\(Y/N\)\n";
chomp($input = <STDIN>);
if ($input eq 'y') {
print "answer yes\n";
} elsif ($input eq 'n') {
print "answer no\n";
$input='y';
}
}
ASKER CERTIFIED SOLUTION
Avatar of bytta
bytta
Flag of Iceland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial