Perhaps someone can help me understand why this is happening. I''m trying to write a script using ''shorewall iprange'' to parse some ip ranges into subnets so that i can place them into the blocklist. I keep getting an error when i run the script though. Here is the script: #!/bin/csh foreach i (`cat ipranges`) shorewall iprange $i >> /etc/firewall/tools/blacklist/blocklist end Here is the error: : syntax error: operand expected (error token is " ") /sbin/shorewall: line 557: [: 67277280: unary operator expected /sbin/shorewall: line 563: [: 67277280: unary operator expected Here are the first few lines of my ipranges file 4.2.145.224-4.2.145.239 4.2.162.160-4.2.162.191 4.2.176.192-4.2.176.223 4.2.179.32-4.2.179.47
davenews@thebarnums.net wrote:> Perhaps someone can help me understand why this is happening. I''m > trying to write a script using ''shorewall iprange'' to parse some ip > ranges into subnets so that i can place them into the blocklist. I > keep getting an error when i run the script though. > > Here is the script: > #!/bin/csh > > foreach i (`cat ipranges`) > > shorewall iprange $i >> /etc/firewall/tools/blacklist/blocklist > > endI don''t have shorewall loaded on a system that has csh installed, but based on the error message, your problem could be a malformed input line in your ipranges file. After taking a quick glance at "man csh", I see that csh supports the -x option. Like bash, adding -x to the csh call will print each line of your script as its executed along with variable substitution. i.e. $i Running csh in this mode should help you locate the source of your problem. Example: #!/bin/csh -x foreach i (`cat ipranges`) shorewall iprange $i >> /etc/firewall/tools/blacklist/blocklist end Steve Cowles
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 davenews@thebarnums.net wrote: | Perhaps someone can help me understand why this is happening. I''m | trying to write a script using ''shorewall iprange'' to parse some ip | ranges into subnets so that i can place them into the blocklist. I keep | getting an error when i run the script though. | | Your script works fine here -- most likely a problem with your /bin/sh. Have you performed the simple test given at http://shorewall.net/shorewall_prerequisites.htm ? - -Tom - -- Tom Eastep \ Nothing is foolproof to a sufficiently talented fool Shoreline, \ http://shorewall.net Washington USA \ teastep@shorewall.net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFBG3MYO/MAbZfjDLIRAol+AKCuuW1g64BIjStJB8maNIM8Tk6n2gCgkUBU ecujlFVwcYVGBa8m49pZPi4=rUFg -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Cowles, Steve wrote: | davenews@thebarnums.net wrote: | |>Perhaps someone can help me understand why this is happening. I''m |>trying to write a script using ''shorewall iprange'' to parse some ip |>ranges into subnets so that i can place them into the blocklist. I |>keep getting an error when i run the script though. |> |>Here is the script: |>#!/bin/csh |> |>foreach i (`cat ipranges`) |> |>shorewall iprange $i >> /etc/firewall/tools/blacklist/blocklist |> |>end | | | I don''t have shorewall loaded on a system that has csh installed, but based | on the error message, your problem could be a malformed input line in your | ipranges file. | | After taking a quick glance at "man csh", I see that csh supports the -x | option. Like bash, adding -x to the csh call will print each line of your | script as its executed along with variable substitution. i.e. $i Running csh | in this mode should help you locate the source of your problem. Example: | | #!/bin/csh -x | | foreach i (`cat ipranges`) | | shorewall iprange $i >> /etc/firewall/tools/blacklist/blocklist | | end | Good idea -- the OP can probably eliminate /bin/sh (see my post) by simply running: shorewall iprange 4.2.145.224-4.2.145.239 from the command line. If that works, then the problem is probably in the data file (maybe DOS format?) - -Tom - -- Tom Eastep \ Nothing is foolproof to a sufficiently talented fool Shoreline, \ http://shorewall.net Washington USA \ teastep@shorewall.net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD4DBQFBG3Q7O/MAbZfjDLIRApUmAJj+77WsxJxE9qKYN1DjXIFzsDTEAKCCCcnJ Wmfr5KJ4jXDpgxJN7d5vBg==L3Pm -----END PGP SIGNATURE-----
Yea, it was a matter of formatting on the range file. Looking at the file in VI i didn''t notice any problems.. no spaces or odd characters but i ran dos2unix on the file and then ran the script and it worked then. Thanks Tom Eastep wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Cowles, Steve wrote: > | davenews@thebarnums.net wrote: > | > |>Perhaps someone can help me understand why this is happening. I''m > |>trying to write a script using ''shorewall iprange'' to parse some ip > |>ranges into subnets so that i can place them into the blocklist. I > |>keep getting an error when i run the script though. > |> > |>Here is the script: > |>#!/bin/csh > |> > |>foreach i (`cat ipranges`) > |> > |>shorewall iprange $i >> /etc/firewall/tools/blacklist/blocklist > |> > |>end > | > | > | I don''t have shorewall loaded on a system that has csh installed, but > based > | on the error message, your problem could be a malformed input line > in your > | ipranges file. > | > | After taking a quick glance at "man csh", I see that csh supports > the -x > | option. Like bash, adding -x to the csh call will print each line of > your > | script as its executed along with variable substitution. i.e. $i > Running csh > | in this mode should help you locate the source of your problem. > Example: > | > | #!/bin/csh -x > | > | foreach i (`cat ipranges`) > | > | shorewall iprange $i >> /etc/firewall/tools/blacklist/blocklist > | > | end > | > > Good idea -- the OP can probably eliminate /bin/sh (see my post) by > simply running: > > shorewall iprange 4.2.145.224-4.2.145.239 > > from the command line. If that works, then the problem is probably in > the data file (maybe DOS format?) > > - -Tom > - -- > Tom Eastep \ Nothing is foolproof to a sufficiently talented fool > Shoreline, \ http://shorewall.net > Washington USA \ teastep@shorewall.net > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.2.4 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD4DBQFBG3Q7O/MAbZfjDLIRApUmAJj+77WsxJxE9qKYN1DjXIFzsDTEAKCCCcnJ > Wmfr5KJ4jXDpgxJN7d5vBg=> =L3Pm > -----END PGP SIGNATURE----- > _______________________________________________ > Shorewall-users mailing list > Post: Shorewall-users@lists.shorewall.net > Subscribe/Unsubscribe: > https://lists.shorewall.net/mailman/listinfo/shorewall-users > Support: http://www.shorewall.net/support.htm > FAQ: http://www.shorewall.net/FAQ.htm >
Dave Barnum wrote:> Yea, it was a matter of formatting on the range file. Looking at the > file in VI i didn''t notice any problems.. no spaces or odd characters > but i ran dos2unix on the file and then ran the script and it worked > then.The vi command :set list can sometimes help spot problems like this. Another that is useful (vim only) is :set fileformat -- Paul Gear, Manager IT Operations, Redlands College 38 Anson Road, Wellington Point 4160, Australia (Please send attachments in portable formats such as PDF, HTML, or OpenOffice.) -- The information contained in this message is copyright by Redlands College. Any use for direct sales or marketing purposes is expressly forbidden. This message does not represent the views of Redlands College.