Why would a command work from the command line but not within a script?
I try to fetch Chappatte's comics from the 'New York Times'
For instance: Code:
lynx -source https://static01.nyt.com/images/2016/09/20/opinion/20chappatte/20chappatte-facebookJumbo.jpg > Chappatte-20160920.jpeg The same happens with Heng's comics. I fetch dozens of other comics with a script. |
Did you set a crontab job? Maybe a path issue then
You should give a full path for Chappatte-20160920.jpeg, not sure if cron would save it in your home, /tmp or elsewhere |
I like to use autoexpect to make scripts. They tend to work more often.
|
Quote:
Code:
wget https://static01.nyt.com/images/2016/09/20/opinion/20chappatte/20chappatte-facebookJumbo.jpg and for the scripting, well, show us the script to see where it fails? |
Quote:
|
1 line of code is not a 'script'.
Show us the whole script and the cron please, or else it's guessing, at best. |
Quote:
|
The whole script:
Code:
#! /bin/bash |
Quote:
Full path it out? |
The script works for me but since I changed the paths it may not be a true test. For the systems (debian and CentOS) that I am working with at the moment lynx is located in /usr/bin.
It depends on how cron's environment is configured. For debian $HOME is set. Are you running this as a cron job or just from the command line? If it does not work from the command line are there any errors? |
/usr/local/bin/lynx path is suspect, should be /usr/bin/lynx in Slackware
$HOME is set in cron env for Slackware as well |
Quote:
By the way can you tell us what's happened at all? Is there any error message somewhere? How did you start this script? |
crontab is irrelevant to this discussion.
I run the script from the command line. I customize lynx so it's in /usr/local/bin. I told you it was correct. It returns 'not found'. The same happens with package lynx on a different computer. I get around the problem by having the script also echo the correct command line so I can copy it with gpm then run it. I didn't want to know another way to do it (wget works) but wanted to understand why there's a difference between running it straight and in a script. snarf (which I usually use for things like this) also doesn't work. |
I overlooked the first line of the script:
Code:
#! /bin/bash |
[see 'Update' first...]
What's "not found"? (probably /usr/local/bin/lynx but it 'IS' there) Try: sh -vx yourNYTscriptfilename and/or put in, as 2nd line: (btw, what editor do you use? vi?) set -vx If you create [the 'SAME way'] a script with just a simple command like ls or df . in it, does it work ok? [maybe; you mentioned other scripts work] Try a script [*created the 'same way'*] with just: (omit 1st !# line [space was ok]) /usr/local/bin/lynx -version Update: I got it [MYscript, using /bin/ls in place of ...lynx] to say ONLY: Quote:
cat'ing the script looks 'ok', like post #8. (same for just ls) Try: od -c yourNYTscriptfilename and *carefully* look for \r or some other 'bad' character. (\n is 'good') How [exactly] do you 'create' your 'nyt' scripts? (Microsoft 'does' \r) |
All times are GMT -5. The time now is 01:17 AM. |