Script not giving o/p


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script not giving o/p
# 1  
Old 09-27-2013
Script not giving o/p

Hi

Below is snippet from script which is not giving the o/p.script name is alarm.sh

Code:
#!/bin/sh
out=`awk '(NR>1) {print $9;exit}' alarm`
  echo $a

however when i simply run the above command i an getting the o/p

Code:
$ out=`awk '(NR>1) {print $9;exit}' alarm`          
$   echo $a
6 --->o/p

request you to please let me for such behavior. as why i am not getting the o/p
# 2  
Old 09-27-2013
You're putting the results of awk in in $out, so shouldn't it be echo $out instead of $a?
# 3  
Old 09-27-2013
Quote:
Originally Posted by scriptor
Code:
#!/bin/sh
out=`awk '(NR>1) {print $9;exit}' alarm`
  echo $a

I think "alarm" should be "alarm.sh", like this...
out=`awk '(NR>1) {print $9;exit}' alarm.sh`

Quote:
Originally Posted by scriptor
however when i simply run the above command i an getting the o/p

Code:
$ out=`awk '(NR>1) {print $9;exit}' alarm`          
$   echo $a
6 --->o/p

request you to please let me for such behavior. as why i am not getting the o/p
i feel, it just executes the "echo $a"

ok, one question... whats there in that alarm.sh?
i feel
Code:
`awk '(NR>1) {print $9;exit}' alarm.sh`

this code is checking if the file alarm.sh is having more than one line or not. if its having more than one line, it prints out the $9(10th field on that file). if alarm.sh is empty, then the awk just exits.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script giving error-Unable to identfiy

#!/bin/sh #!/bin/prel #set -x while getopts ":n:t:" opt; do case "$opt" in n) host=$OPTARG ;; t) targ=$OPTARG ;; *) break ;; esac done if ping -c 2 $host >/dev/null 2>&1 then echo Host... (17 Replies)
Discussion started by: Vishal_dba
17 Replies

2. Shell Programming and Scripting

Giving Input in a script

Hi, I am a newbie to scripting. I want to know something..Is there any way that I can do this? Here is the thing.. there are so many printer queues in which i need to change a certain option.. am using the hppi utility and i need to modify the printer configuration individually going to each... (3 Replies)
Discussion started by: aksijain
3 Replies

3. Shell Programming and Scripting

$0 not giving script name

Why does $0 return the word usage rather than the script name when used in a function? Baffeled on this one, any help appreciated. usage() { echo "$0 -cs <number of batches>\n" echo "$0 -c 4" echo "$0 -s 4" # echo "-c = Create" # echo "-s = Submit\n" exit 1 } $... (1 Reply)
Discussion started by: nhatch
1 Replies

4. Shell Programming and Scripting

My script is not giving result for 2 or more arguments

Hi, I am new to shell scripting and my below script is not giving result for 2 or more arguments. Can anyone help pls. #!/bin/sh sname=$(basename $(readlink -nf $0)) echo "This is $sname, running at $(date)" echo "It is running on $(hostname)" echo "Script being run by" echo " User... (3 Replies)
Discussion started by: baigmd
3 Replies

5. Shell Programming and Scripting

how to run the script without giving the password.

Hi all, I need some help in my script... I need to login into multiple servers from one Unix box and need to login as a superuser account and then I need to perform some actions on the server. For this, i'll use for loop to provide the server names to the script, but for every login as a... (8 Replies)
Discussion started by: raghu.iv85
8 Replies

6. Shell Programming and Scripting

awk script giving unstable results

Hi all Here I came accross a situation which i am unable to reason out... snippet 1 psg ServTest | grep -v "grep" | grep -v "vi" | awk '{ pgm_name=$8 cmd_name="ServTest" gsub(/]*/,"",pgm_name) if(pgm_name==cmd_name) { print "ServTest Present =" cmd_name} }'... (10 Replies)
Discussion started by: Anteus
10 Replies

7. UNIX for Advanced & Expert Users

script giving error

Hi All, i have an small issue... echo " " eval x=$@ export x=`echo $x` echo $x ssh user@ipadrss; cd /mbbv/home/; cd /mbbv/home/orange/orange/ echo pwd bash samplescript.sh $x above is my script which will triger from server A and will connect to server B for some... (2 Replies)
Discussion started by: Shahul
2 Replies

8. Shell Programming and Scripting

script not giving the desired output

Hi, I have a script in which an entry like this ..... FILENAME_B="PIC_${DATE}0732*.JPG" The script connects to an ATM and pull a pic file from it.The format for the file is like PIC_2008061400000001.JPG in the ATM. Means 1st 8 digit is the date(YYYYMMDD) field 2nd 8 digit means hrs... (2 Replies)
Discussion started by: Renjesh
2 Replies

9. Shell Programming and Scripting

Script giving wrong results....

hi, I have this script which gives me the result... #! /usr/bin/sh set -x cd /home/managar a=1 while true do if then echo " File log.txt exists in this directory " exit 0 fi echo " File has not arrived yes..." sleep 3 let a=a+1 if then (1 Reply)
Discussion started by: mgirinath
1 Replies

10. Shell Programming and Scripting

Giving input through script

Script 1.ksh ========= /home/adw/a.ksh << ** a b Script 1.ksh is working fine even without ending "**" Script 2.ksh ========= if then /home/adw/a.ksh << ** a b fi But the script 2.ksh is giving error "syntax error : `<<' unmatched". Is it bcoz of fi. (1 Reply)
Discussion started by: radhika03
1 Replies
Login or Register to Ask a Question