parameter passing


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting parameter passing
# 1  
Old 07-19-2006
Data parameter passing

Hallo everyone,

This is my problem below:

/home/cerebrus/pax=>vat class2.sh
ksh: vat: not found
/home/cerebrus/pax=>cat class2.sh
#!/bin/ksh
set -x
bdf|grep appsdev|awk '{ print $5 }'> class3
dd={cat class3}
echo $dd
/home/cerebrus/pax=>
/home/cerebrus/pax=>./class2.sh
+ bdf
+ awk { print $5 }
+ grep appsdev
+ 1> class3
+ class3}
+ dd={cat
./class2.sh[4]: class3}: not found
+ echo

I would like $dd to give me the percentage for /appsdev

Regards,

Paxley
email address removed
# 2  
Old 07-19-2006
The rules say

(10) Don't post your email address and ask for an email reply. The forums are for the benefit of all, so all Q&A should take place in the forums.


Change this line
Code:
dd={cat class3}

to
Code:
dd=$(<class3)

# 3  
Old 07-19-2006
Vino, It worked. Thank you very much.
# 4  
Old 07-20-2006
I have another question:

Have a look at my script. What am i doing wrong?

Code:
/home/cerebrus/pax=>./class2.sh
+ bdf
+ awk { print $5 }
+ grep appsdev
+ 1> class3
+ dd=59%
+ [ 59% -gt 95% ]
./class2.sh[8]: 59%: more tokens expected
+ echo FILES WONT BE DELETED
FILES WONT BE DELETED
+ echo 59%
59%

Code:
/home/cerebrus/pax=>cat class2.sh
#!/bin/ksh
set -x
bdf|grep appsdev|awk '{ print $5 }'> class3
#dd='cat class3'
dd=$(<class3)
#export $dd
#if [ 'grep '$dd' class3|wc -l' -gt 0 ]
if [ $dd -gt 95% ]
then
echo "FILES WILL BE DELETED"
else
echo "FILES WONT BE DELETED"
echo $dd
fi
/home/cerebrus/pax=>


Last edited by vino; 07-20-2006 at 06:20 AM.. Reason: introduced code tags
# 5  
Old 07-20-2006
Get rid of the '%' in the variable dd.
-gt works on numbers. 59% and 95% are not numbers. You need to extract the number out that and then run the script.

Change
Code:
dd=$(<class3)
if [ $dd -gt 95% ]

to
Code:
dd=$(<class3)
dd=${dd%\%}
if [ $dd -gt 95 ]

Not tested tho'.

Last edited by vino; 07-20-2006 at 06:50 AM.. Reason: correction...
# 6  
Old 07-20-2006
Its not working:

/home/cerebrus/pax=>./class2.sh
+ bdf
+ awk { print $5 }
+ grep appsdev
+ 1> class3
+ dd=
+ [ -gt 95 ]
./class2.sh[8]: test: argument expected
+ echo FILES WONT BE DELETED
FILES WONT BE DELETED
+ echo

/home/cerebrus/pax=>
# 7  
Old 07-20-2006
This is how the code looks like:

/home/cerebrus/pax=>cat class2.sh
#!/bin/ksh
set -x
bdf|grep appsdev|awk '{ print $5 }'> class3
dd=${dd%\%} #'cat class3'
##dd=$(<class3)
#export $dd
#if [ 'grep '$dd' class3|wc -l' -gt 0 ]
if [ $dd -gt 95 ]
then
echo "FILES WILL BE DELETED"
else
echo "FILES WONT BE DELETED"
echo $dd
fi
/home/cerebrus/pax=>
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing parameter through file

Hi , I am passing date parameter through file my shell script testing.sh is #set -x #set -v asd=$1 asd1=$2 echo $asd echo $asd1 Passing parameter as below sh testing.sh `cat file1.txt` Output (2 Replies)
Discussion started by: kaushik02018
2 Replies

2. Shell Programming and Scripting

Passing parameter more than 9

Hi, I've written a script where eleven parameter to be passed from command line which is inserting into an oracle table, it is working but the tenth and 11th parameter are not accepting as given it is referring to 1st parameter. HERE IS THE SCRIPT #!/bin/ksh #set -o echo $*... (4 Replies)
Discussion started by: sankar
4 Replies

3. Shell Programming and Scripting

Passing parameter to script, and split the parameter

i am passing input parameter 'one_two' to the script , the script output should display the result as below one_1two one_2two one_3two if then echo " Usage : <$0> <DATABASE> " exit 0 else for DB in 1 2 3 do DBname=`$DATABASE | awk -F "_" '{print $1_${DB}_$2}` done fi (5 Replies)
Discussion started by: only4satish
5 Replies

4. Shell Programming and Scripting

Passing a parameter to AWK

Hi All, I am trying to pass a parameter to AWK on my KSH shell prompt as below. var1=2 echo $var1 awk -v var2=${var1} '{print var2}' testfile.txt I am passing the input file (testfile) to awk to get some o/p. It is having 10 records. When I run AWK, it is throwing the following errors... (1 Reply)
Discussion started by: Raamc
1 Replies

5. Shell Programming and Scripting

Positional parameter passing

Hi All, When passing parameters to a sheel script, the parameters are referenced by their positions such as $1 for first parameter, $2 for second parameter. these positional values can only have values ranging from $0-$9 (0,1,2,3...9). I have a shell script meant to accept 20 parameters. for... (3 Replies)
Discussion started by: ogologoma
3 Replies

6. Shell Programming and Scripting

Passing parameter in quotes

Hi, PW='/as sysdba'; export PW in other module I call sqlplus ${PW} (this line I unable to change!) How I can define PW so that sqlplus calls PW in quotes i.e sqlplus '/as sysdba' I tried like this PW="'/as sysdba'"; export PW - no luck Thanks in advance (2 Replies)
Discussion started by: zam
2 Replies

7. Shell Programming and Scripting

Parameter Passing problem

Hi All, I developed a KSH script which will accept two parameters as input. These two parameters are some directories paths. In the script i am validating the number of paramaters it received as below #-------------------------------------- # Check Command line arguments... (8 Replies)
Discussion started by: Raamc
8 Replies

8. Shell Programming and Scripting

Passing asterisk As A Parameter

I have written a Shell Script Program which accepts 3 parameters as shown below: ./calc 20 + 2 in the above line ./calc is the Shell Script itself with 3 parameters, namely: 20 + and 2. Well, now let's look inside the Script: result=$1$2$3 echo $result The output will be as... (8 Replies)
Discussion started by: indiansoil
8 Replies

9. Shell Programming and Scripting

wrong parameter passing!

Hi all I have a script which will take input as filename and passes it to a java program. It is as follows -------------------------------- FILENAME=$1 echo $FILENAME ${JAVA_HOME}/bin/java -cp DateProvider $FILENAME ------------------------------------------------- when I execute the same... (2 Replies)
Discussion started by: malle
2 Replies

10. Programming

Passing parameter to makefile?

Hi, How to pass parameter to makefile? Please let me know if any one knows and also please put an example of makefile with this feature. thanks, Manju. (3 Replies)
Discussion started by: manju_p
3 Replies
Login or Register to Ask a Question

Featured Tech Videos