LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-12-2004, 06:20 PM   #1
coyote399
Member
 
Registered: Feb 2004
Distribution: Debian Sarge
Posts: 30

Rep: Reputation: 15
basic shell script help


This is my first attempt at a shell script. What I am trying to do is get the pictures off www.website.com/[10-60]/. I know cURL supports doing that, but it wont recursively download, so I tried to put together this script to do it. Can someone tell me what is wrong with this?

Code:
#!/bin/bash

let i=10

while [ $i >= 10 ] ; [ $i <= 60 ]
do
    wget -r -l2 -A jpg,jpeg http://www.website.com/$i/
    let i=$i+1
done
echo "done"
the output is

./wget2.sh: line 5: [: 10: unary operator expected
./wget2.sh: line 5: [: 10: unary operator expected
 
Old 04-12-2004, 06:29 PM   #2
AutOPSY
Member
 
Registered: Mar 2004
Location: US
Distribution: Redhat 9 - Linux 2.6.3
Posts: 836

Rep: Reputation: 31
why dont you use like && instead of ;

; is a line break from the shell,
&& means a if a is true otherwise b. I beleive.
A and b being your two [ ] [ ] conditionals.

also || is or. you decide.
 
Old 04-12-2004, 06:32 PM   #3
coyote399
Member
 
Registered: Feb 2004
Distribution: Debian Sarge
Posts: 30

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by AutOPSY
why dont you use like && instead of ;

; is a line break from the shell,
&& means a if a is true otherwise b. I beleive.
A and b being your two [ ] [ ] conditionals.

also || is or. you decide.
Okay, sounds good, but there still must be something wrong.

Code:
#!/bin/bash

let i=10

while [ $i >= 10 ] && [ $i <= 660 ]
do
    wget -r -l2 -A jpg,jpeg http://www.site.com/$i/
    let i=$i+1
done
echo "done"
./wget2.sh: line 5: [: 10: unary operator expected

Last edited by coyote399; 04-12-2004 at 06:34 PM.
 
Old 04-12-2004, 06:32 PM   #4
aaa
LQ Guru
 
Registered: Jul 2003
Location: VA
Distribution: Slack 10.1
Posts: 2,194

Rep: Reputation: 46
Guess: Use 'expr' to evaluate expressions?
 
Old 04-12-2004, 06:34 PM   #5
coyote399
Member
 
Registered: Feb 2004
Distribution: Debian Sarge
Posts: 30

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by aaa
Guess: Use 'expr' to evaluate expressions?
can you elaborate and/or give an example on how to do this?
 
Old 04-12-2004, 06:50 PM   #6
cmfarley19
Member
 
Registered: Nov 2002
Location: Central VA
Distribution: Ubuntu/Debian
Posts: 228

Rep: Reputation: 32
Bash has (comparitively) goofy syntax for logical expressions.

When dealing with numerical vaues, use -gt, -lt, -ge, -le... for >, <, >=, <= respectively.
Like so...
Code:
#!/bin/bash

let i=10

while [ $i -ge 10 ] && [ $i -le 660 ]
do
    wget -r -l2 -A jpg,jpeg http://www.site.com/$i/
    let i=$i+1
done
echo "done"
Let us know if that works...
 
Old 04-14-2004, 10:22 PM   #7
coyote399
Member
 
Registered: Feb 2004
Distribution: Debian Sarge
Posts: 30

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by cmfarley19
Bash has (comparitively) goofy syntax for logical expressions.

When dealing with numerical vaues, use -gt, -lt, -ge, -le... for >, <, >=, <= respectively.
Like so...
Code:
#!/bin/bash

let i=10

while [ $i -ge 10 ] && [ $i -le 660 ]
do
    wget -r -l2 -A jpg,jpeg http://www.site.com/$i/
    let i=$i+1
done
echo "done"
Let us know if that works...
Thanks, that works great!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 06:32 PM
Help with basic bourne shell script rnj Programming 6 09-13-2005 09:41 PM
Basic Shell Script Help Vasquez Linux - Newbie 3 02-28-2005 08:14 PM
basic shell script help lin00b Linux - Newbie 2 10-09-2004 12:32 AM
Basic shell script, please help colly Linux - General 4 10-05-2004 12:24 PM


All times are GMT -5. The time now is 03:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration