The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
BASH condition for "File older than 1 hour" Squeakygoose Shell Programming and Scripting 2 02-16-2009 03:06 PM
The "PS" command was displaying*terminals named as "SYSCON" kiranjose85 UNIX for Advanced & Expert Users 1 11-28-2008 07:53 AM
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-20-2007 01:52 AM
bash: cd command to access "strange" directories robotronic Shell Programming and Scripting 3 07-06-2007 05:35 PM
Unix "at" / "Cron" Command New Problem...Need help Mohanraj UNIX for Dummies Questions & Answers 3 01-26-2006 08:08 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-17-2009
jbsimon000 jbsimon000 is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 12
Unhappy Reading lines from a file, using bash, "at" command

Hi.
I have the script shown below. If I execute it form the command line it seems to work properly, but when I fun it using the unix "at" command
"at -m now < ./kill-at-job.sh"
It appears to hang. Below is the script, the input file, and the execution as reported in the e-mail from the "at" processor. This is running on sunOS,
version 5.8.

Thanks !
Joe Simon

The script :

#!/bin/bash
#

set -x

# Get Info from :
# ~/builds/scripts/at-job.log
#
AT_LOG_FILE_NAME=~/builds/scripts/at-job.log

LINE_COUNT=0
while read LINE
do
# Need to skip first line, at job name is on 2nd line
if [[ $LINE_COUNT -eq 1 ]] ; then
set -- $LINE
AT_JOB="$2"
echo "AT Job ID = $AT_JOB"
break
fi
LINE_COUNT=$(($LINE_COUNT+1))
done < $AT_LOG_FILE_NAME

echo "Loop Complete"

The input file looks like this:

commands will be executed using /bin/bash
job 1237304740.a at Tue Mar 17 11:45:40 2009

The log file e-mailed to me looks like this:

Your "at" job on xxxx
"/var/spool/cron/atjobs/1237303896.a"

produced the following output:

+ AT_LOG_FILE_NAME=/xxx/builds/scripts/at-job.log
+ LINE_COUNT=0
+ read LINE
+ [[ 0 -eq 1 ]]
+ LINE_COUNT=1
+ read LINE
+ [[ 1 -eq 1 ]]
+ set -- job 1237304740.a at Tue Mar 17 11:45:40 2009
+ AT_JOB=1237304740.a
+ echo 'AT Job ID = 1237304740.a'
AT Job ID = 1237304740.a
+ break


If I remove the break (this is what I originally had), the execution looks like this:

+ AT_LOG_FILE_NAME=/export/home4/a10/simonj/builds/scripts/at-job.log
+ LINE_COUNT=0
+ read LINE
+ [[ 0 -eq 1 ]]
+ LINE_COUNT=1
+ read LINE
+ [[ 1 -eq 1 ]]
+ set -- job 1237304740.a at Tue Mar 17 11:45:40 2009
+ AT_JOB=1237304740.a
+ echo 'AT Job ID = 1237304740.a'
AT Job ID = 1237304740.a
+ LINE_COUNT=2
+ read LINE
  #2 (permalink)  
Old 03-17-2009
Goldorakk's Avatar
Goldorakk Goldorakk is offline
Registered User
  
 

Join Date: Feb 2009
Location: France
Posts: 43
Is there any data in ~/builds/scripts/at-job.log ???
  #3 (permalink)  
Old 03-17-2009
jbsimon000 jbsimon000 is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 12
Quote:
Originally Posted by Goldorakk View Post
Is there any data in ~/builds/scripts/at-job.log ???

Yes
"
The input file looks like this:

commands will be executed using /bin/bash
job 1237304740.a at Tue Mar 17 11:45:40 2009"

and you can see in the execution
"+ echo 'AT Job ID = 1237304740.a'
AT Job ID = 1237304740.a"

So it is reading the file, but getting stuck
I don't unnerstand it.
  #4 (permalink)  
Old 03-17-2009
jbsimon000 jbsimon000 is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 12
well, I did not solve the problem, but I got around it by putting all of my processing in the "if" statement and performing an exit 0 after I did what I needed to. Would be nice to know what I am doing wrong, however.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:53 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0