When I run a Linux "at" command,I find the user's shell script executed fail, for example,I write the following code in my script

 #!/bin/csh  #or #!/bin/bash
 echo "Now will excute a shell script"

When I run the script in the command line, It's works fine.

While I run that using the "at" command,follwing message will be shown

Now will excute a shell script dir=/home/Jim/Desktop:Command not found my_path="/home/Jim":Command not found

I tried lots of times,but can still now work

So Please anybody can help me to fix this problem.Thank you & Regards!

  • 1
    how do you use at ? – Archemar Mar 30 '16 at 7:40
  • bash and csh are "!=" , does your script really have both at the top? Is it a bash script, or a csh script? (Are single quotes & backticks the same in bash & csh?) – Xen2050 Mar 30 '16 at 16:38
  • I means if using #!/bin/csh or #!/bin/bash,the error info will both be shown. – Liuwei.Shi Apr 1 '16 at 0:58

When you using backticks at the shell or in a script it attempts to execute the contents as if it was a program.

This line is trying to execute the program named /home/Jim, but I believe from what I can get out of your question, this is your home directory, not an executable program. So what you almost certainly need to do is put the /home/Jim in quotes, not backticks (`).

  • His error shows that /home/Jim is double quoted and it seems like whatever this at is, it runs dir=/home/Jim/Desktop and my_path="/home/Jim" as commands – Tom Yan Mar 30 '16 at 8:49
  • Look closer at his error. It is Command not found. You don't get a command not found error when trying to save a string to a variable. Unfortunately the OP's formatting question formatting was sorta messed up, so I can't say this with 100% certainty, but sure seems very likely to me that he has backticks instead of quotes. – Zoredache Mar 30 '16 at 16:29
  • You misunderstood me. I mean the at treated the whole lines as commands, as if dir=/home/Jim/Desktop and my_path="/home/Jim" are programs. – Tom Yan Mar 30 '16 at 18:29
  • Oh, at is a tool that lets you run your command at some later point in time. Mostly people use cron instead, but at is still installed by default on lots of distros. I was assuming the OP was just doing something like echo "scriptpath" | at {time}, but maybe not. – Zoredache Mar 30 '16 at 20:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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