Sign up ×
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 am trying to download images from a manufacturer's site using wget. When I run the command from the shell it works fine. But when I run it from a file I am getting a placeholder file.

Here is the command:

wget --wait=2 --output-document=1000.jpg ''

Here is what it looks like in a file:

wget --wait=5 --output-document=1101.jpg ''
wget --wait=5 --output-document=1102.jpg ''
wget --wait=5 --output-document=1103.jpg ''

I can't figure out why it isn't working as a batch shell file.

share|improve this question

migrated from Jul 13 '11 at 0:07

This question came from our site for professional and enthusiast programmers.

It's probably something small that's tripping it. Check this page for more info though - –  Adel Jul 12 '11 at 23:38
What does the placeholder contain? Are you invoking the script from the same shell where the direct call works? In particular, were the proxy settings the same? –  Gilles Jul 13 '11 at 0:12
What is "Doesn't work"? What exactly is the output when it "Doesn't work"? How are you invoking it? Is this from a cron job? Are you passing it to a shell e.g. bash Are you executing by path e.g. ./ –  Sorpigal Jul 13 '11 at 11:45

3 Answers 3

You know that you need to add an x (execute) flag on Unix to execute a shell script? Another common pitfall for DOS users is that for security reasons there is often no "." in the PATH Environment thus you need to run "./your-script" instead of just "your-script".

Concerning the she-bang mentioned in the other answer. At least on Linux /bin/sh is the default shell used if no she-bang is given inside the script. It is still good practice to always add one to all scripts.

share|improve this answer

I tested it here, and it worked fine. Do you have a she-bang line at the top? #!/path/to/shell

share|improve this answer
What do you mean? –  coolbluelogo Jul 12 '11 at 23:58
For bash it would be: #!/bin/bash –  Johan Jul 13 '11 at 11:35
That depends on where bash is located. On my box, it's /usr/local/bin/bash ;) –  AlexWebr Jul 13 '11 at 12:02
Try #!/usr/bin/env bash - most systems place env in /usr/bin, so it's pretty portable. The down side is that it's easy to intercept by adding a custom bash interpreter earlier in your PATH. –  Sorpigal Jul 13 '11 at 14:38

Get the output from

which bash


which wget

then add the returned path to bash at the top of your script with a hash bang(#!). i.e if which bash return /bin/bash then use.


Then add the returned path for wget. example

/usr/bin/wget --wait=5 --output-document=1101.jpg '

finally make sure the script you have created is executable chmod +x name-of-your-script

If its not working still try adding -x to your script to get some debugging info.

#!/bin/bash -x
share|improve this answer

Your Answer


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