Sponsored Content
Full Discussion: Script not giving o/p
Top Forums Shell Programming and Scripting Script not giving o/p Post 302857721 by inventsekar on Friday 27th of September 2013 03:41:29 AM
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.
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
ALARM(2)						     Linux Programmer's Manual							  ALARM(2)

NAME
alarm - set an alarm clock for delivery of a signal SYNOPSIS
#include <unistd.h> unsigned int alarm(unsigned int seconds); DESCRIPTION
alarm arranges for a SIGALRM signal to be delivered to the process in seconds seconds. If seconds is zero, no new alarm is scheduled. In any event any previously set alarm is cancelled. RETURN VALUE
alarm returns the number of seconds remaining until any previously scheduled alarm was due to be delivered, or zero if there was no previ- ously scheduled alarm. NOTES
alarm and setitimer share the same timer; calls to one will interfere with use of the other. sleep() may be implemented using SIGALRM; mixing calls to alarm() and sleep() is a bad idea. Scheduling delays can, as ever, cause the execution of the process to be delayed by an arbitrary amount of time. CONFORMING TO
SVr4, SVID, POSIX, X/OPEN, BSD 4.3 SEE ALSO
setitimer(2), signal(2), sigaction(2), gettimeofday(2), select(2), pause(2), sleep(3) Linux 1993-07-21 ALARM(2)
All times are GMT -4. The time now is 07:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy