09-11-2002
Hello Helen,
echo "$var" | grep [^a-zA-Z0-9] >/dev/null
will return a 0 if $var is "bin*" because the grep is only serching for alphabetic characters and numbers.
Plus if you do: echo "$var"
This will return: bin*
However, if you do(without quotes): echo $var
This will return: bin binary ....
If you do want * to be a valid character you can put a (backslash) \ before it in the grep statement. This turns off any special meanings of such characters.
Hope this answers your question.
Regards
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Please Help! :o
I have a main script (ksh) where another script is called (convert_picture). Normally this works ok, but since some changes has been made on the unix-server (I dont know what :( ) suddenly it doesnt work anymore: i get an error message: ksh: convert_picture not found. I am... (3 Replies)
Discussion started by: Rakker
3 Replies
2. Shell Programming and Scripting
hey guys. i have a bunch of programs in a script that needs to run as root and the rest as another user, we'll call him gabriel.
now, in this script, i want to run the first few lines as root. now, how do i, after running as root, tell the script to run the remaining lines as the user gabriel?... (3 Replies)
Discussion started by: Terrible
3 Replies
3. Shell Programming and Scripting
Hi
Please help me with the following problem with my script.
The following block of code is not repeating in the while loop and exiting after searching for first message.
input_file
==========
host001-01
host001-02
2008-07-23 13:02:04,651 ConnectionFactory - Setting session state... (2 Replies)
Discussion started by: pcjandyala
2 Replies
4. Shell Programming and Scripting
hi,,
i have perl scipt with line :
system('./try.sh $t $d $m');
in shell scipt try.sh i have the line:
echo $1
its not printing value of $t that i hav passed..y is it so..i am running it from apache web server (2 Replies)
Discussion started by: raksha.s
2 Replies
5. UNIX for Dummies Questions & Answers
Hello All. I have a script that is suppossed to start up a daemon but when executed, simply hangs. Could you please take a look and let me know where the problem might be? TIA
###################################################################
#
# SCRIPT: dstart3000.sh
# Bring up the Domain... (6 Replies)
Discussion started by: grin1dan
6 Replies
6. Shell Programming and Scripting
Hi everyone,
I got a problem with a script. What it's supposed to do is:
to take as arguments a directory name <dir> and a dimension (in byte) <dim>;
if <dir> exists, to write name and dimension of every regular file within it that sizes lesser than <dim> in regFileList.
Nothing happens... (10 Replies)
Discussion started by: Luke Bonham
10 Replies
7. Shell Programming and Scripting
Hi all,
I have a script that calls another program/script, xxx, to run in the background. Supposedly this program at most should finish within five (5) minutes so after five (5) minutes, I run some other steps to run the script into completion.
My problem is sometimes the program takes... (5 Replies)
Discussion started by: newbie_01
5 Replies
8. Shell Programming and Scripting
Hi ,
I have moduled my scripts in three scripts .
From First script i am calling second and from second i am calling third for some check .
Problem is with the third script call.
---In second script
EXP ='test.\abc.\Server.*abc.xml.*'
pid=$($HOME/bin/checkpid $EXP)
--Third... (2 Replies)
Discussion started by: amrishn
2 Replies
9. Shell Programming and Scripting
Hello,
Ubuntu server 11.10
can anybody help what is problem with my shell script?
#!/bin/bash
#script to find out currently logged on user is root or not.
if ]
then
echo "You are super"
else
echo "You are awesome!"
fi
When I run script, I get following output
./uid: line 3:
I... (4 Replies)
Discussion started by: kaustubh
4 Replies
10. Shell Programming and Scripting
Hi team,
I have a script in different folder. Now i want to call that script and execute that script from that path alone.
My code is
#!/bin/bash
wname=yahoo
PATH='/opt/IBM'
wac=`/usr/bin/ls $PATH | /usr/bin/grep "$wname"`
STOP=`/usr/bin/find $PATH/$wac -type f -name "stop.sh"`... (8 Replies)
Discussion started by: natraj005
8 Replies
LEARN ABOUT DEBIAN
escape
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)