Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a shell script that accepts an argument and uses that in the script. So to run the script I type /path/to/script argument

The problem is when trying to setup that file to run using the at utility. I have tried

at -f /path/to/script argument 17:45

at -f '/path/to/script argument' 17:45

but neither of these options work. First one receives a syntax error and the second says no such file Any suggestions?

share|improve this question
2  
Just put /path/to/script argument in another script, and call that script instead. –  warl0ck Oct 25 '12 at 0:57
1  
That pretty much defeats the purpose of having arguments in the shell script. Thanks though! –  Elmer Oct 25 '12 at 14:46

3 Answers 3

up vote 4 down vote accepted

Since at defaults to reading from standard input, you can just do this:

echo /path/to/script argument | at 17:45
share|improve this answer

I would recommend following the advice of @warl0ck in the general case -- create a new script, e.g. /path/to/newscript:

 #!/bin/bash
 /path/to/script argument

and then run that using at:

 at -f /path/to/newscript 17:45

This makes it easy to adjust whatever arguments are needed, run multiple commands, etc.

Alternatively, for occasional or one-off use, you can just run at with the chosen time, and then enter whatever command(s) you need on standard input; hit ctrl-D to end:

 myhost# at 17:45
 /path/to/script argument
 <ctrl-D>
 Job 1 will be executed using /bin/sh
share|improve this answer

I had this issue too. This is starting a ssh connection to sshserverhost that executes test.sh with parameter $HOSTNAME on the remote server, sshserverhost.

at now + 1 minutes <<EOF
ssh -t sshserverhost 'bash -s' <~/test.sh $HOSTNAME
EOF 
share|improve this answer
    
Is this an answer to the OP's question, or are you saying you have the issue too... –  eyoung100 11 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.