-
bash scripts escape char problems
hi everyone i am trying to use the backslash escape char when writting an iptables script the problem im having its it doesnt work.
if i type the iptables command into the shell it works fine with backslash spaces. what do i need to do to get the script to work with \ char ? i find it strange that it works on the command line fine but when its in a script file it doesnt.
-
my iptable script test works fine i tried it on my other linux box and it worked the escap char work perfect. i still cant figure out why it wont on my slackware box thou ...... its using bash 3.x.x i think
-
Perhaps you aren't using a bash shell. To be sure, you should start the file with:
#!/bin/bash
If that doesn't work, we're going to need an example of what you're talking about.
-
im using bash . and i have #!/bin/bash in my script thats given. the \ at end of line doesnt work .
example would be
iptables -F
iptables -A INPUT -i eth0 \
-p icmp --icmp-type echo-request \
-m limit --limit 1/second -j log
the script whould give me an error telling me the -p isnt a command which is given. and in otherwords the \ right after eth0 isnt working. if i type that command in the command line prompt it works perfect with no error . im currently learning iptables.
-
and oh yearh i meant to cap the LOG -m limit --limit 1/second -j LOG
just a type o sorry about that
-
Did you originally create this file on a Microsoft or Apple OS? If so, Linux may be seeing garbage at the end of each line. (\n\r\c)
Can you post the file so that we can inspect it ourselves? (zip it first)
-
NO i dont use windows........i use vi to create it what im use to use its not the file
its in text...... its a problem with bash and iptables ..... not the text file which is created with vi.......
-
the only thing i can think of is the kernel is missing options to not let lptables use blackslash. because it works on the box i compiled fine but doesnt on the test 2.6.13 slackware kernel .
-
Originally Posted by crow2icedearth
the only thing i can think of is the kernel is missing options to not let lptables use blackslash. because it works on the box i compiled fine but doesnt on the test 2.6.13 slackware kernel .
That's ridiculous, there are no kernel options that have to do with how you type stuff in in bash.
What's the output of 'file yourscript.sh' ? backslash escaping newlines works fine for me the way you're doing it. Try catting the text in instead of using an editor:
and then paste in your script, or something simple like:
Code:
sudo \
whoami
echo this is\
totally working.
Hit ctrl-d when you're done pasting.
-
no but the iptables relies on the kernel to have it netfilters ......
-
well that seemed to work...... so is the problem vim not keymapping correctly ?
-
now it seems to work in vim. thts a very strang problem...... rebooted the machine and it all works fine
-
Solved?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|