Solved need help on error

Code:
#!/bin/csh
fetch -i /tmp/german.zone -o /tmp/german.zone "http://www.ipdeny.com/german.zone"
sed -i '' "s/;.*//" /tmp/german.zone
ipfw table 2 flush
foreach IP ( `cat /tmp/german.zone` )
       ipfw table 2 add $IP
end

I got this code but get the error that the file name is exogenous showing /tmp/german

I changed german to german.txt

the url fetch is correct and deliberately put a wrong path. The issue is that ipfw spits that error out and refuses to populate the table.

it spits out:

ipfw: exogenous filename argument. I then check the tables and find no ip addresses added.

Any ideas as to why I am getting this error?
 
The filename has nothing to do with ipfw(8) since you pass the file's content only.
Have you checked what do you eventually get in /tmp/german.zone?
The sed command doesn't seem to be correct, what is '' for?
Also, correct me if I'm wrong, ipdeny.com provides lists in form of a.b.c.d/xx lines, there are no semicolons.
 
The filename has nothing to do with ipfw(8) since you pass the file's content only.
Have you checked what do you eventually get in /tmp/german.zone?
The sed command doesn't seem to be correct, what is '' for?
Also, correct me if I'm wrong, ipdeny.com provides lists in form of a.b.c.d/xx lines, there are no semicolons.


I took out the sed line. This is a script from here: https://serverfault.com/questions/265038/block-ip-addresses-with-ipfw

I am trying to modify it to use ipdeny.com

the
/tmp/german.zone file has ip blocks of ip addresses in germany. I can run in the command terminal a cat /tmp/german.zone and see the list of ip blocks. They're there.

However, in the script ipfw spits out what I said before or when playing around with the cat string. I at times would get a error saying cat isn't a hostname.

What I am trying to do is populate a ipfw table from a file that holds german ip addresses.

I have the list but what I have currently it's just not populating ipfw tables. It just keeps saying the
ipfw: exogenous filename argument. error. The tables are set too so they do exist but are empty.
 
The original script operates on lists in form of 23.226.48.0/20 ; SBL322605. It removes the semicolon and all the rest. The list you mentioned "http://www.ipdeny.com/german.zone" does not exist, but correct lists at ipdeny do not have that "; abcd" tail. However, it does not matter in the context of your error.
So, what's in the list you get with fetch?
The only way to get the error you mentioned is to feed a filename to ipfw.

EDIT: By the way, the actual error spelled correctly looks like:
Code:
ipfw: extraneous filename arguments /path/to/file
which is self-explanatory: an extra argument in form of filename is supplied.
 
The original script operates on lists in form of 23.226.48.0/20 ; SBL322605. It removes the semicolon and all the rest. The list you mentioned "http://www.ipdeny.com/german.zone" does not exist, but correct lists at ipdeny do not have that "; abcd" tail. However, it does not matter in the context of your error.
So, what's in the list you get with fetch?
The only way to get the error you mentioned is to feed a filename to ipfw. It's JIJO: junk in ― junk out :)

EDIT: By the way, the actual error spelled correctly looks like
Code:
ipfw: extraneous filename arguments /path/to/file
which is self-explanatory: an extra argument in form of filename is supplied.


In the german.zone file I got exaclty this: http://ipdeny.com/ipblocks/data/aggregated/de-aggregated.zone that's the actual link on the site and I just download that file but rename it to german.zone. The file looks exactly like that.


This is what I have currently:

Code:
#!/bin/csh
fetch -i /tmp/german.zone -o /tmp/german.zone "http://www.ipdeny.com/german.zone"
ipfw table 2 flush
foreach IP ( `cat /tmp/german.zone` )
      ipfw table 2 add $IP
end

When I echo $IP it shows cat /tmp/german.zone.

Yeah it looks like it's passing in /tmp/german.zone to $IP. I don't know why.

If I in command type cat /tmp/german.zone I will see the list of ip blocks.

If I type in command echo $IP it shows cat /tmp/german.zone.

pretty much like you said it looks like it's feeding /tmp/german.zone to ipfw as $IP and I have no clue why. What is $IP is it a returning variable from the function IP?
 
The original script operates on lists in form of 23.226.48.0/20 ; SBL322605. It removes the semicolon and all the rest. The list you mentioned "http://www.ipdeny.com/german.zone" does not exist, but correct lists at ipdeny do not have that "; abcd" tail. However, it does not matter in the context of your error.
So, what's in the list you get with fetch?
The only way to get the error you mentioned is to feed a filename to ipfw.

EDIT: By the way, the actual error spelled correctly looks like:
Code:
ipfw: extraneous filename arguments /path/to/file
which is self-explanatory: an extra argument in form of filename is supplied.

Yeah but how do you fix the error? I googled around and found many postings and articles on the net that indicate that the script should work properly.

Eveyone says to get content from a file into a variable just do set variable="cat filepath" and that should be it where variable should now contain the contents of the file in the filepath.

The problem is I do exactly that but it doesn't do exactly that. The cat commant seems to take the contents of the file and show them in the screen. I need to take the contents out from the file and put them inside a variable.

How would you do this in c shell? Every place on the internet insist cat followed by name of file is all you need.

However, when I do cat I see the contents printed to the screen. Yet, when I echo variables from my script I only see the actual text of cat followed by filepath. I don't see the actual contents of the actual file.

The file I downloaded has a list of IP addresses. I need to do a foreach loop so that every ip block in the file will be grabbed and will be inserted into a table in the IPFW firewall. The problem here is I cannot get the contents of the file aka the ip blocks and put the contents into a variable.

Do you do it by using cat? Or is there another function that I would need to call to read the contents of the file?
 
to get content from a file into a variable just do set variable="cat filepath"
This is wrong, the expression has to be in back-quotes: variable=`cat filepath`, which means to assign the result of the command.
However, the script you provided above is correct, it contains back-quotes and works (if I use the actual link).
So please check your actual script again, if you have double quotes around cat /tmp/german.zone, you'll get that error.
 
This is wrong, the expression has to be in back-quotes: variable=`cat filepath`, which means to assign the result of the command.
However, the script you provided above is correct, it contains back-quotes and works (if I use the actual link).
So please check your actual script again, if you have double quotes around cat /tmp/german.zone, you'll get that error.


I don't have double quotes. I even tried doing this set pizza='cat /tmp/german.zone'

then I do ipfw table 2 add $pizza and ipfw keeps giving me the same error. When I echo pizza out. I see the text cat /tmp/german.zone if I don't have ' ' or " " around it I get a error saying cat unknown command.


also at the top of the script it shows this
#!/bin/csh -f
 
Code:
#!/bin/sh
fetch -o /tmp/german.zone http://ipdeny.com/ipblocks/data/aggregated/de-aggregated.zone
ipfw table 2 flush
for IP in $( cat /tmp/german.zone ); do
    ipfw table 2 add ${IP}
done
When in doubt, make it simple. ;) SH is much easier to work in than CSH. $( ) syntax is so much nicer than ` ` syntax, and eliminates the whole back-tick vs apostrophe issue.
 
Back
Top