Linux scripting - wget loop
Hi all :)
Basically, I want to have a script, that runs wget to download and backup some files off my webserver. I've been trying to "add" a number and run it in a loop, but unfortunately, the leading zero's were gone after that. This is the script, that should be run: # !/bin/sh # Backup files from webserver #echo backing up files.. NUMBER="0001" echo wget "h**p://shadow/edata/ed"$NUMBER".inf" (can't post the url due to forum restrictions) The next file, it should try to get via wget is 0002, 0003, 0004, you get the point :) the file range is currently 0001 - 0250.. Would any of you have an idea of how to get that up and running? Thanks in advance! |
This is a quick and dirty (very dirty) way of doing it:
Code:
#!/bin/bash |
Thank you very much for your fast reply!
When I tried to execute the script, I got an "lt: binary operator expected" error in line 3, so I changed the lt to -lt. I then got an error in line 8. After a google search, I added the quotation marks, that works fine as well now :) When running the script now, I get following output: ./backup: line 4: [: +lt: binary operator expected wget h**p://shadow/edata/ed{241}.inf <- (it's counting up from 1 to 250 okay, seems like the {} are not needed). But when I change the lt in line4 to -lt, nothing happens, the script just hangs... Getting very close :) this is the current script: Code:
#!/bin/bash |
Did you try adding 'echo' to test the output? If not, try that...
I'm not exactly sure what is wrong without seeing the error messages. |
Yes, the script is exactly as in the last post.
When running it, it shows ./backup: line 4: [: lt: binary operator expected wget h**p://shadow/edata/ed{241}.inf ./backup: line 4: [: lt: binary operator expected wget h**p://shadow/edata/ed{242}.inf ./backup: line 4: [: lt: binary operator expected wget h**p://shadow/edata/ed{243}.inf ./backup: line 4: [: lt: binary operator expected wget h**p://shadow/edata/ed{244}.inf ./backup: line 4: [: lt: binary operator expected wget h**p://shadow/edata/ed{245}.inf etc. :) |
I did something identical to what you're asking for to download webcomics this summer, only using Perl.
Code:
#!/usr/bin/perl -w Code:
#include <stdio.h> Code:
#include <stdio.h> |
Incidentally, in the bash version, you've only converted the 1st instance of 'lt' => '-lt'. you need to do the same to the 2nd instance, which funnily enough is line 4 (!) as per the error msg... ;)
|
Hey again :)
I did not see the posts from yesterday, so I sat down with a friend of mine and analyzed the script, and we got it working :) if anyone is interested, here it is: Code:
#!/bin/bash |
All times are GMT -5. The time now is 02:13 AM. |