Find the answer to your Linux question:
Results 1 to 4 of 4
I am new to scripting and am hoping someone won't mind providing some guidance. I think I have my error trapped. I'm trying to write a script that will run ...
  1. #1
    Just Joined!
    Join Date
    May 2011
    Posts
    3

    Wget related script

    I am new to scripting and am hoping someone won't mind providing some guidance. I think I have my error trapped.

    I'm trying to write a script that will run multiple wget commands, one after another. For simplicity's sake, I have been trying to get the script to work with just one wget command. The purpose of this script is to check online pdf files for changes and download the new files if changes have been made.

    My working directory is /sdcard/wget. For each wget command, I will have a list of URLs contained in a text file. In this example the file is ppm.txt. If I type at the prompt # wget -P ./app/ppm -N --append-output=log.txt -i ppm.txt, the pdf files specified at the URL in ppm.txt will download and save in the /sdcard/wget/app/ppm directory. No problems.

    I put the exact same command into a file and saved it as run.sh. If I execute this file via the command # sh run.sh it logs the error:

    ppm.txt
    : No such file or directory
    No URLs found in ppm.txt
    .

    It seems strange to me, but I obviously have a problem either with my script file or with the way I am trying to execute the script. I have set permissions of the entire folder to chmod 777....

    Thanks in advance, I really appreciate any help.

    C.

  2. #2
    Just Joined!
    Join Date
    May 2011
    Posts
    3
    Some more information regarding current permissions...

    All of this is on a Barne's and Noble Nook Color android device running CM7. I have busybox v1.18.4 installed. When I chmod 777 the run.sh file and then ls-l I see the following permissions:

    ----rwxr-x

    From what I gather online a 777 should be rwxrwxrwx. Could the issue be that for one reason or another I haven't set owner execute permissions on this file?

    If I attempt to execute the script via # ./run.sh i get "permission denied"

    Thanks...

  3. #3
    Just Joined!
    Join Date
    Sep 2010
    Posts
    5
    You can maybe try something like this:

    Code:
    LIST_OF_URLS=$EXTERNAL_STORAGE/wget/ppm.txt
    OUTPUT_DIR=$EXTERNAL_STORAGE/wget/app/ppm
    
    for i in $( cat $LIST_OF_URLS ); do
       busybox wget $i -O $OUTPUT_DIR/$( busybox basename $i )
    done
    You should use the $EXTERNAL_STORAGE variable on Android instead of /sdcard. Try "sh $EXTERNAL_STORAGE/wget/name_of_script.sh" to get rid of the permission denied.

    Hopefully that was somewhat helpful.

  4. #4
    Just Joined!
    Join Date
    May 2011
    Posts
    3
    Good suggestion... Here is what I put in the run.sh script file:

    wget -P $EXTERNAL_STORAGE/wget/app/ppm -N --append-output=$EXTERNAL_STORAGE/wget/log.txt -i $EXTERNAL_STORAGE/wget/ppm.txt

    Funny thing is that the log file returns:
    /mnt/sdcard/wget/ppm.txt
    : No such file or directory
    No URLs found in /mnt/sdcard/wget/ppm.txt

    From reading a little bit about android, the sdcard is fat32 which I guess doesn't support standard unix permissions.

    Since I'm now using absolute paths, I tried putting the run.sh file in /system/xbin and running it from there but I still get the same error.

    Next I tried putting run.sh back into the sdcard/wget directory and tired running it two ways. It executes (but returns the error) with the command #sh run.sh but it returns "permission denied" with the command ./run.sh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...