Reading lines from a file, using bash, "at" command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reading lines from a file, using bash, "at" command
# 1  
Old 03-17-2009
Data 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  
Old 03-17-2009
Is there any data in ~/builds/scripts/at-job.log ???
# 3  
Old 03-17-2009
Quote:
Originally Posted by Goldorakk
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  
Old 03-17-2009
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. UNIX and Linux Applications

Problem on SQLplus command ""bash: sqlplus: command not found""

Hi all, i face an error related to my server ""it's running server"" when i use sqlplus command $ sqlplus bash: sqlplus: command not found the data base is up and running i just need to access the sqlplus to import the dump file as a daily backup. i already check the directory... (4 Replies)
Discussion started by: clerck
4 Replies

3. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

4. UNIX for Dummies Questions & Answers

"Help with bash script" - "License Server and Patch Updates"

Hi All, I'm completely new to bash scripting and still learning my way through albeit vey slowly. I need to know where to insert my server names', my ip address numbers through out the script alas to no avail. I'm also searching on how to save .sh (bash shell) script properly.... (25 Replies)
Discussion started by: profileuser
25 Replies

5. Shell Programming and Scripting

Find lines with "A" then change "E" to "X" same line

I have a bunch of random character lines like ABCEDFG. I want to find all lines with "A" and then change any "E" to "X" in the same line. ALL lines with "A" will have an "X" somewhere in it. I have tried sed awk and vi editor. I get close, not quite there. I know someone has already solved this... (10 Replies)
Discussion started by: nightwatchrenba
10 Replies

6. Shell Programming and Scripting

Cat Command on File not printing "Blank" Lines?

Hello All, I have a bash script and in it at some point I call an Expect Script that does some stuff and saves its output in a ".txt" file. Example "/path/to/my/file/Expect_Output.txt" file: notice the 2nd line is empty in the file... Data for Host-1 (192.168.1.110) Checking the... (2 Replies)
Discussion started by: mrm5102
2 Replies

7. UNIX for Dummies Questions & Answers

Unix "look" Command "File too large" Error Message

I am trying to find lines in a text file larger than 3 Gb that start with a given string. My command looks like this: $ look "string" "/home/patrick/filename.txt" However, this gives me the following message: "look: /home/patrick/filename.txt: File too large" So, I have two... (14 Replies)
Discussion started by: shishong
14 Replies

8. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

9. AIX

Typing "bash" at the command line spawns two bash processes

Server: IBM p770 OS: AIX 6.1 TL5 SP1 When one of our develoeprs types "bash" on the command line to switch shells, it hangs. For some reason, two bash processes are created....the first bash process spawns a second bash process in the same console, causing a hang. Anyone have any idea what... (2 Replies)
Discussion started by: wjssj
2 Replies

10. Shell Programming and Scripting

Simplify Bash Script Using "sed" Or "awk"

Input file: 2 aux003.net3.com error12 6 awn0117.net1.com error13 84 aux008 error14 29 aux001.ha.ux.isd.com error12 209 aux002.vm.ux.isd.com error34 21 alx0027.vm.net2.com error12 227 dux001.net5.com error123 22 us008.dot.net2.com error121 13 us009.net2.com error129Expected Output: 2... (4 Replies)
Discussion started by: sQew
4 Replies
Login or Register to Ask a Question