03-17-2009
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
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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
2. AIX
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
3. Shell Programming and Scripting
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
4. UNIX for Dummies Questions & Answers
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
5. Shell Programming and Scripting
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
6. Shell Programming and Scripting
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
7. UNIX for Dummies Questions & Answers
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
8. UNIX for Dummies Questions & Answers
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
9. UNIX and Linux Applications
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
10. Shell Programming and Scripting
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
LEARN ABOUT CENTOS
tap::parser::scheduler::job
TAP::Parser::Scheduler::Job(3) User Contributed Perl Documentation TAP::Parser::Scheduler::Job(3)
NAME
TAP::Parser::Scheduler::Job - A single testing job.
VERSION
Version 3.28
SYNOPSIS
use TAP::Parser::Scheduler::Job;
DESCRIPTION
Represents a single test 'job'.
METHODS
Class Methods
"new"
my $job = TAP::Parser::Scheduler::Job->new(
$filename, $description
);
Given the filename and description of a test as scalars, returns a new TAP::Parser::Scheduler::Job object.
Instance Methods
"on_finish"
$self->on_finish(&method).
Register a closure to be called when this job is destroyed. The callback will be passed the "TAP::Parser::Scheduler::Job" object as it's
only argument.
"finish"
$self->finish;
Called when a job is complete to unlock it. If a callback has been registered with "on_finish", it calls it. Otherwise, it does nothing.
Attributes
$self->filename;
$self->description;
$self->context;
These are all "getters" which return the data set for these attributes during object construction.
"filename"
"description"
"context"
"as_array_ref"
For backwards compatibility in callbacks.
"is_spinner"
$self->is_spinner;
Returns false indicating that this is a real job rather than a 'spinner'. Spinners are returned when the scheduler still has pending jobs
but can't (because of locking) return one right now.
perl v5.16.3 2013-05-02 TAP::Parser::Scheduler::Job(3)