Garbled time when feeding `at` with $NROFHOURS

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Garbled time when feeding `at` with $NROFHOURS
# 1  
Old 08-16-2011
Garbled time when feeding `at` with $NROFHOURS

Hi forum,

I'm trying to set an at job in a script.

I collect some info, set the amount of hours in a variable and then try to use this variable to set the at job.

A shortened version of the script (with the same result) goes as follows:

NROFHOURS=`read hours`
echo "ls" | /usr/bin/at now + $NROFHOURS hours

When I run that, I get this:
syntax error. Last token seen: hours
Garbled time

I have tried everything I could think of to put it differently:
- put quotes from now to hours
- use the at -f <script> <time> format
- put <now + $NROFHOURS hours> in one variable
- ...

None would work.

Do you guys have any idea please?


Last edited by Scott; 08-16-2011 at 05:36 AM.. Reason: Code tags
# 2  
Old 08-16-2011
#!/bin/bash read NROFHOURS echo "$NROFHOURS"

# 3  
Old 08-16-2011
Thanks! That seemed to work (and it's simpler). Unfortunately I cannot directly use it in my script: here's what I'm doing:
set -- `getopt -q h: "$@"`

# Check that both options are given / if not: print usage
if [ $# -lt 2 ]
        echo "Usage : $0 -h <nrofhours>"

# process cli options
while [ -n "$1" ]
        case "$1" in
                -h) NROFHOURS="$2"
                        echo "You want to schedule it $NROFHOURS hours ahead."
                        shift ;;
                --) shift
                        break ;;
                *)  echo "$1 is not an option" ;;

/usr/bin/at -f $HOME/test/ now + $NROFHOURS hours

Would you know how to get around this?


---------- Post updated at 12:22 AM ---------- Previous update was at 12:19 AM ----------

Anyone please?

When I run the above code, I get this:

You want to schedule it '8' hours ahead.
syntax error. Last token seen: '
Garbled time

Last edited by Scott; 08-16-2011 at 05:37 AM.. Reason: Please use code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to run feeding each other processes simultaneously?

Hello, I need to run multiple shell processes simultaneously and output of the first process shall be the input of the second process but first process is never ending so both should be running in parallel. I do not wish to wait the end of the first process. I am under ubuntu 16.04. ... (3 Replies)
Discussion started by: baris35
3 Replies

2. Shell Programming and Scripting

Problem with feeding password while changing to root user

i want to change user to "root" from another user while running a script. how can i automatically feed the password? for example, i want to write a script say ""... it will first run the command "p" as mhmn user, and then it will change the user to "root" by using "su - root" command. at... (1 Reply)
Discussion started by: mhmn
1 Replies

3. Shell Programming and Scripting

Parsing text file and feeding it into an executable

Hello, everyone. I am working wtihin AIX 5.3, and I need to do the following: read the each line of file BASE.txt do XK {line contents} if XK's output begins with "BASE", then append line contents to file "output.txt" continue until end of file Here is what I tried(unsuccessfuly): ... (4 Replies)
Discussion started by: Mordaris
4 Replies

4. Shell Programming and Scripting

Feeding information in columns of LOG file

Dear all, I want to write a shell script to easy my job. Here is the description of task: I have several files (d1.log, d2.log, d3.log etc) with the common text as =======using photon counter ====== tot pho is = 29596 nomatch pho is = 1350 phoeta pho is = 1220... (11 Replies)
Discussion started by: nrjrasaxena
11 Replies

5. Shell Programming and Scripting

Feeding password in bash script

Hello I am doing some test. In a script I have to call a change password routine ( ldap ) which ask confirmation. This can be done from terminal. Is there a way to do something like this : #!/bin/bash # blabla blabla blabla blabla # changing_password_routine user_name... (2 Replies)
Discussion started by: jcdole
2 Replies

6. Shell Programming and Scripting

feeding interactive shell commands

Hi, like if i want to authenticate and i 100% know the password and username i can run a script with su - username and then feed in the password through file pass.txt < pass.txt but if i don't know in which order the script is going to prompt for the input is there a way i... (4 Replies)
Discussion started by: ltoso
4 Replies

7. Shell Programming and Scripting

Loop assistance, getting array of random numbers and feeding to a command, how-to?

Hi all, I need a little assistance to complete the following script. I would like to take a file with a single number on each line and for each number, run it through a command. The loop will terminate once all numbers have been checked. Here is what I have thus far... COUNTER=`wc -l... (2 Replies)
Discussion started by: boolean2222
2 Replies

8. Solaris

feeding filenames to find command

Hi, I am having set of files whose names are stored in a file say "filelist.txt" Now, I want to find all files contained in "filelist.txt" from my parent directory. Is there any way to let find command understand "filelist.txt" just like we have option -f in awk. I donot want to run a... (4 Replies)
Discussion started by: sanjay1979
4 Replies

9. Shell Programming and Scripting

problem feeding netcat a list of hosts

Hi, I'm having difficulty in making a bash script to get netcat to scan a list of hosts and their ports from another file and could use some help. Here's an example host list, "": 22 And here's the first script I tried to feed "" into netcat: "" ... (3 Replies)
Discussion started by: seanovision
3 Replies

10. Shell Programming and Scripting

Garbled Sed w/variables

I'm trying to get a partial file path by passing the part I want removed to sed. Sed gets garbled when I try multiple directories (i.e. because of the extra slash). For example: FULLFILEPATH="usr/local/bin" STRIPDIR="usr" PARTFILEPATH=`echo $FULLFILEPATH | sed s/\${STRIPDIR}//` Gives me... (3 Replies)
Discussion started by: bergerj3
3 Replies
Login or Register to Ask a Question