04-23-2010
Quote:
Originally Posted by
bongo
I corrected that... but error still apears
Please forgive me if you actually posted what the error is, and I can't see it,
but I just can't see it!
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi
I have a doubt in the way the variables inside a function are treated .
if a function is called from the main script directly, the variables inside them act as global variables.
however if the return value of the function is stored to some other variable in the main script as shown,... (3 Replies)
Discussion started by: prez
3 Replies
2. Shell Programming and Scripting
Guys,
I´m have this problem and I do not know what to do anymore:
cod=`sqlplus -s ${DATABASE} << EOF
set heading off feedback off verify off
select max(eventid) from events;
exit
EOF`
sed "s/CODEVENTID/${cod}/" c.ctl
Abova What I´ve done. The CODEEVENTID is already set into a... (1 Reply)
Discussion started by: Rafael.Buria
1 Replies
3. Shell Programming and Scripting
Hi all
I would like to know if there is a way to return an array for a function.
As I know function can return all the contents in an array, I want to return an array type. (6 Replies)
Discussion started by: dophine
6 Replies
4. Shell Programming and Scripting
how to return value from function and print from main program???
And also I need to return true or false... Is it possible? (5 Replies)
Discussion started by: darshakraut
5 Replies
5. Shell Programming and Scripting
I have write a shell function to get the maximum of a vector.
However, the returned value from the function is not always
the correct one.
Here is the script:
maxval()
{
local max j i size arrval
size=$1 ; shift
max=-999999999
i=0
while
do
arrval="$1"
if
then
... (5 Replies)
Discussion started by: fl0r10
5 Replies
6. Shell Programming and Scripting
I am using ksh. I want to know how can we make any function to return string or double value.
I dont want to use the global variables. (5 Replies)
Discussion started by: PRKS
5 Replies
7. Shell Programming and Scripting
I have two scripts. script1.sh looks
--------------------------------
#!/bin/bash
display()
{
echo "Welcome to Unix"
}
display
-----------------------------
Script2.sh
#!/bin/bash
sh script1.sh //simply calling script1.sh
------------------------------ (1 Reply)
Discussion started by: mvictorvijayan
1 Replies
8. Shell Programming and Scripting
Not sure where the problem is. I can run the script without any issue using the following command.
. /opt/app/scripts/cdc_migration.sh
But it fails with the below error when I try it this way
/opt/app/scripts/cdc_migration.sh
/opt/app/scripts/cdc_migration.sh: line 65: return: can only... (1 Reply)
Discussion started by: svajhala
1 Replies
9. Shell Programming and Scripting
Hi All,
Good Day, seeking for your assistance on how to not perform my 2nd, 3rd,4th etc.. function if my 1st function is in else condition.
#Body
function1()
{
if
then
echo "exist"
else
echo "not exist"
}
#if not exist in function1 my all other function will not proceed.... (4 Replies)
Discussion started by: meister29
4 Replies
LEARN ABOUT CENTOS
shell-quote
SHELL-QUOTE(1) User Contributed Perl Documentation SHELL-QUOTE(1)
NAME
shell-quote - quote arguments for safe use, unmodified in a shell command
SYNOPSIS
shell-quote [switch]... arg...
DESCRIPTION
shell-quote lets you pass arbitrary strings through the shell so that they won't be changed by the shell. This lets you process commands
or files with embedded white space or shell globbing characters safely. Here are a few examples.
EXAMPLES
ssh preserving args
When running a remote command with ssh, ssh doesn't preserve the separate arguments it receives. It just joins them with spaces and
passes them to "$SHELL -c". This doesn't work as intended:
ssh host touch 'hi there' # fails
It creates 2 files, hi and there. Instead, do this:
cmd=`shell-quote touch 'hi there'`
ssh host "$cmd"
This gives you just 1 file, hi there.
process find output
It's not ordinarily possible to process an arbitrary list of files output by find with a shell script. Anything you put in $IFS to
split up the output could legitimately be in a file's name. Here's how you can do it using shell-quote:
eval set -- `find -type f -print0 | xargs -0 shell-quote --`
debug shell scripts
shell-quote is better than echo for debugging shell scripts.
debug() {
[ -z "$debug" ] || shell-quote "debug:" "$@"
}
With echo you can't tell the difference between "debug 'foo bar'" and "debug foo bar", but with shell-quote you can.
save a command for later
shell-quote can be used to build up a shell command to run later. Say you want the user to be able to give you switches for a command
you're going to run. If you don't want the switches to be re-evaluated by the shell (which is usually a good idea, else there are
things the user can't pass through), you can do something like this:
user_switches=
while [ $# != 0 ]
do
case x$1 in
x--pass-through)
[ $# -gt 1 ] || die "need an argument for $1"
user_switches="$user_switches "`shell-quote -- "$2"`
shift;;
# process other switches
esac
shift
done
# later
eval "shell-quote some-command $user_switches my args"
OPTIONS
--debug
Turn debugging on.
--help
Show the usage message and die.
--version
Show the version number and exit.
AVAILABILITY
The code is licensed under the GNU GPL. Check http://www.argon.org/~roderick/ or CPAN for updated versions.
AUTHOR
Roderick Schertler <roderick@argon.org>
perl v5.16.3 2010-06-11 SHELL-QUOTE(1)