MegaKaskaskas
MegaKaskaskas

Reputation: 129

Pass arguments to script that is redirected to at

I have a simple command:

/usr/bin/at -m now < /home/test/script.sh

I want to pass arguments to script.sh.

Unfortunately this isn't working:

/usr/bin/at -m now < /home/test/script.sh arg1 arg2

It throws error:

syntax error. Last token seen: a

Garbled time

Does anyone know how to do it? I've tried dozen of quotes, slashes and stuff like that for arguments. Each one of them throws different error.

Solution below won't work for me because I have to run it inside another bash script.

/home/test/script.sh arg1 | at now

Upvotes: 1

Views: 169

Answers (1)

Socowi
Socowi

Reputation: 27205

Your problem is, that you either execute script.sh or pass its source to at. But at just wants some command string like (literally) script.sh args.

Try bash's here strings

at now <<< "/home/test/script.sh arg1 arg2"

which is equivalent to

echo "/home/test/script.sh arg1 arg2" | at now

Upvotes: 3

Related Questions