bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#17637: bug "cut of end-line is skipped"


From: rd
Subject: bug#17637: bug "cut of end-line is skipped"
Date: Thu, 29 May 2014 23:43:25 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

helo, i'm a bash shell script beginner...
forgive my poor English, i'd like to contribute to GNU O.S. reporting this suspect bug.

it was working perfectly the command from
ubuntu 12.04 LTS after installed "at" using the terminal command apt-get install at

#################################
 echo "`atq`" |cut -d$'\n' -f1  | cut -d$'\t' -f1
#################################

return the first number job id  from the scheduler atq Job list.
exaple: 9432 or 9486 or ... 9498

it was working perfectly the follow routine from my implementation for video surveillance in shell script running like root user:
##################################
##################################
#! /bin/sh
#
Kill_All_Jobs()
{
local Job_Pid=""
local Done=false
local Empty=""
while [ "$Done" = false  ]
do
    Job_Pid=""
    # set first line
    Job_Pid=$( echo "`atq`" |cut -d$'\n' -f1 )
    # set first field
    Job_Pid=$( echo "$Job_Pid" | cut -d$'\t' -f1 )
    if [ "$Job_Pid" != "$Empty" ]
    then
        echo "KILLING JOB $Job_Pid"
        at -r "$Job_Pid"
        echo ""
        sleep 1
    else
        Done=true
    fi
done
}
##################################
##################################


Now after Upgrade to ubuntu 14.04 LTS
the command
#################################
 echo "`atq`" |cut -d$'\n' -f1  | cut -d$'\t' -f1
#################################
give to a different output result!
example output is

94234
94356
94237

in the same bash variable..
i hope mistake, i think the cut of tabulator is done but the cut of end-line is skipped! so the result is a set of values that make the routine in loop .. the at -r command can't operate without a correct parameter variable value.

after some time.. i replaced the routine using a rea-file-line instruction and temporarily solved

##################################
Kill_All_Jobs()
{
local Job_Pid=""
local Done=false
local Empty=""
local Temp_location="$VS_ROOT"
local Temp_name="atq.sh"
local Tmp_File="$Temp_location$Temp_name"
local line=""
while [ "$Done" = false  ]
do
    atq > "$Tmp_File"

    Job_Pid=""
    line=""
    while read line
    do
        #set first filed
        Job_Pid=$( echo "$line" | cut -d$'\t' -f1 )
        echo "line..$line..$Job_Pid.."
    done < "$Tmp_File"

    if [ "$Job_Pid" != "$Empty" ]
    then
        echo "KILLING JOB ..$Job_Pid.."
        at -r "$Job_Pid"
        echo ""
        sleep 1
    else
        Done=true
    fi
done
kill "$Tmp_File"
}


##################################
good rule of developing is avoid to use files not necessary...

so i'd like to have reply from the follow questions:
1- what is the correct syntax to use cut with atq command to extract the job id? 2- the output from shell commands use the same field separator and line separator?
3- there is a standar output format or metod from shell commands?

thanks regard ... rudy






reply via email to

[Prev in Thread] Current Thread [Next in Thread]