Sponsored Content
Top Forums Shell Programming and Scripting Shell script automation using case statement Post 28013 by ianf on Wednesday 11th of September 2002 08:26:55 AM
Old 09-11-2002
Shell script automation using case statement

Hi,

I'm trying to write a shell script that has a menu and then dependant on the selection, will automate some samba file transfer.

The problem is when I run the code without the case statement it runs fine. but when I put the case statement in the only way I can get the code to run is to remove the "SMB_1" entries but then the samba commands are no longer automated. Help please !!

Code is below :

#!/bin/sh
#
################
#Deployment script
################

echo " Please select one of the following :

1. Upload from dev platform
2. End

Please enter choice : "
read sel

case $sel in
1) echo "going to upload from dev ..."
/opt/samba/bin/smbclient //devsyst1/packages$ -Wdevsyst11 -Uadministrator << SMB_1
tar c syst_update.tar NewSyst
exit
SMB_1
gzip syst_update.tar
;;
*) echo "gone"
;;
esac


Any ideas ?Smilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

lower case to upper case string conversion in shell script

How can convert a Lower case variable value to an upper case in the kron shell script. (3 Replies)
Discussion started by: dchalavadi
3 Replies

2. Shell Programming and Scripting

what is problem with this small shell script.. case statement related

Hi All, this small script is written to recognize user input character.. it is in small case .. upeer case or is a number... but when i input first capital letter say A.. it always gives small character.... what is the problem. #!/bin/bash echo "Enter the character" read a case $a in )... (2 Replies)
Discussion started by: johnray31
2 Replies

3. Shell Programming and Scripting

shell script case statement

In a case statement like below : case $rental in "car") echo "For $rental Rs.20 per k/m";; "van") echo "For $rental Rs.10 per k/m";; "jeep") echo "For $rental Rs.5 per k/m";; "bicycle") echo "For $rental 20 paisa per k/m";; *) echo "Sorry, I can not gat a $rental for you";;... (4 Replies)
Discussion started by: sriram003
4 Replies

4. Shell Programming and Scripting

Shell case statement

echo -e "Select: \c" read IN pattern="1-20" case $IN in ) echo "Selected: $IN" ;; *) echo "Invalid selection: $IN" ;; esac # sh test Select: 10 Invalid selection: 10 # sh test Select: 2 (6 Replies)
Discussion started by: Ikon
6 Replies

5. Shell Programming and Scripting

Help With Loop in Case Statement script

I am writing a bash script that asks the user for input and I need it to repeat until the user selects quit.. I dont know how to write the loop for it I searched all over but i still do not get it.. if anyone could help with this it would be greatly apprciated here is my script so far: #!... (2 Replies)
Discussion started by: Emin_Em
2 Replies

6. Shell Programming and Scripting

Pass values to case statement in a function korn shell

I'm in the process of writng a function that consists of a case statement is there a way of calling the function and passing a value to it? ie function1 () { case opt1 do ..... opt2 do..... esac } function opt1 I'm aware the syntax is not correct, but you get the general idea. (1 Reply)
Discussion started by: squrcles
1 Replies

7. Shell Programming and Scripting

Case statement in UNIX shell script

have written the below code to check whether the string received from user is a file name or dir using case statement, but its going into default case*). #!/bin/sh #Get a string from user and check whether its a existing filename or not rm str2 rm str3 echo "enter a file \c" read fil... (8 Replies)
Discussion started by: Mohan0509
8 Replies

8. Shell Programming and Scripting

Using shell to generate case statement

Hi Gurus, I have a very weird requirement and have no clue to resolve the issue. please help me get out this difficulty below two tables, table1 contains the column name. D means this column used for the rule. for example: rule 0 is all columns have value, rule1 is col3 and col7 have no value.... (2 Replies)
Discussion started by: Torhong
2 Replies

9. Shell Programming and Scripting

Shell scripting with case statement

Foe example we have three environments int,qa and prod.Each environment has some number of servers. int=Server1,Server2,Server3 qa=Server4,Server5,Server6 prod=Server7,Server8,Server9 echo "Enter the Environment i.e int,qa,prod" read env case $env in int) ## Need command where all the... (9 Replies)
Discussion started by: nareshreddy443
9 Replies

10. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies
escape(1)							Mail Avenger 0.8.3							 escape(1)

NAME
escape - escape shell special characters in a string SYNOPSIS
escape string DESCRIPTION
escape prepends a "" character to all shell special characters in string, making it safe to compose a shell command with the result. EXAMPLES
The following is a contrived example showing how one can unintentionally end up executing the contents of a string: $ var='; echo gotcha!' $ eval echo hi $var hi gotcha! $ Using escape, one can avoid executing the contents of $var: $ eval echo hi `escape "$var"` hi ; echo gotcha! $ A less contrived example is passing arguments to Mail Avenger bodytest commands containing possibly unsafe environment variables. For example, you might write a hypothetical reject_bcc script to reject mail not explicitly addressed to the recipient: #!/bin/sh formail -x to -x cc -x resent-to -x resent-cc | fgrep "$1" > /dev/null && exit 0 echo "<$1>.. address does not accept blind carbon copies" exit 100 To invoke this script, passing it the recipient address as an argument, you would need to put the following in your Mail Avenger rcpt script: bodytest reject_bcc `escape "$RECIPIENT"` SEE ALSO
avenger(1), The Mail Avenger home page: <http://www.mailavenger.org/>. BUGS
escape is designed for the Bourne shell, which is what Mail Avenger scripts use. escape might or might not work with other shells. AUTHOR
David Mazieres Mail Avenger 0.8.3 2012-04-05 escape(1)
All times are GMT -4. The time now is 06:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy