wget inside the sh script.
Greetings all,
It's my first message is this forum that some friends recommended me. I'm starting with administering a linux server with Centos version and it's long way to go, because I do not control the operating system as much as I would like. Right now I'm here with you because I have a problem with a sh script I've written, this one has within it several wget. When I run the script from the command line works without problems but when I run it from crontab does not work. I wonder if I can count on your support to tell me I'm doing wrong. This is the script: Code:
#!/bin/sh |
If you're running commands from crontab, you probably want to use the full command (e.g. /usr/bin/wget) as cron runs in a limited environment, so probably doesn't have the same $PATH variable as you do.
|
> I wonder if I can count on your support to tell me I'm doing wrong.
We couldn't tell, but your computer can: Code:
#!/bin/sh |
Hello NevemTeve & Snark1994;
Thanks a lot for your reply, following yours recommendations at the end of the script would be: #!/bin/sh exec >/tmp/cron.debug.$$ 2>&1 set -x cd /root/ /usr/bin/wget http://www.midomain/phpscript.php?secc=32 /usr/bin/wget http://www.midomain/phpscript.php?secc=19 /usr/bin/wget http://www.midomain/phpscript.php?secc=10 /usr/bin/wget http://www.midomain/phpscript.php?secc=29 /usr/bin/wget http://www.midomain/phpscript.php?secc=24 /usr/bin/wget http://www.midomain/phpscript.php?secc=20 /usr/bin/wget http://www.midomain/phpscript.php?secc=26 /usr/bin/wget http://www.midomain/phpscript.php?secc=27 /usr/bin/wget http://www.midomain/phpscript.php?secc=13 /usr/bin/wget http://www.midomain/phpscript.php?secc=37 /usr/bin/wget http://www.midomain/phpscript.php?secc=23 /usr/bin/wget http://www.midomain/phpscript.php?secc=83 /usr/bin/wget http://www.midomain/phpscript.php?secc=34 (echo "Push was sucefull" && exit 0 ) || ( echo "Push failed" && exit 1) Please excuse me for my ignorance and lack of knowledge about it, because it shows that it is essential for you. I will implement the script and tomorrow I will comment if it worked. thanks a lot again. |
Quote:
|
Please use ***[code][/code]*** tags around your code and data, to preserve the original formatting and to improve readability. Do not use quote tags, bolding, colors, "start/end" lines, or other creative techniques.
Does this have to be a POSIX-compliant /bin/sh script, or can you use bash instead? If so, it can be re-written to be much shorter and cleaner. Code:
#!/bin/bash arrays brace expansion You could also skip the array and use the brace expansion directly in wget, but I think it's cleaner to pre-prepare the url list before downloading. Note too that the original final line was incorrect. Since it never tested the outcome of wget, the script would always evaluate as successful. Not to mention that it would only be checking the result of the final instance anyway. If the code has to be posix, I suggest this instead: Code:
#!/bin/bash command substitution Posix can be bit trickier when it comes to creating lists of things to operate on. Since it doesn't have arrays you have to depend on shell word splitting, and that's often difficult to do safely. But that's not a big worry here, as the urls don't have whitespace in them. Finally, you may also want to consider using the mktemp command instead of relying on '$$' for the tempfile. |
Hello David
Your reply is incredible ...! Many thanks for the enormous contribution, but (and I apologize if you abuse your generosity) the link will now contain a setting that I have to generate in the script, this parameter is the MD5 of the date but the value of a constant. Example: Constan: XYZ=´qwerty01´ parameter= md5(date().XYZ) Can you tell me how I can do this you are asking me? Beforehand I am enormously grateful for your help. This can be done or I´m totally crazy....? Thanks again for your reply. Quote:
|
Sorry, I'm afraid I don't quite understand your new requirement. Where exactly does the extra parameter need to go? Do you mean that each url has to contain a different string? If so, you'll need to load the array with a loop instead.
Please post a detailed example of the new data strings, exactly how they need to be generated, and how they need to be used. And as I said before, please use [code][/code] tags around all of your code and data. |
All times are GMT -5. The time now is 10:04 PM. |