LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   running a command with paramaters it obtains from a file (https://www.linuxquestions.org/questions/linux-newbie-8/running-a-command-with-paramaters-it-obtains-from-a-file-454039/)

eNtoS 06-12-2006 11:14 AM

running a command with paramaters it obtains from a file
 
Hi

How can i run a command and in the middle of it, get text from a file?

e.g. i want to call the command:
iptables -I FORWARD 10 -p udp -m udp -s READDATAFROMAFILE -d 192.168.1.1 --dport 1111 -j ACCEPT

and READDATAFROMFILE should be replaced by the contents of the file "myip"

Cheers!

cs-cam 06-12-2006 06:15 PM

Code:

iptables -I FORWARD 10 -p udp -m udp -s $(cat /path/to/file.txt) -d 192.168.1.1 --dport 1111 -j ACCEPT
Make sure you have some integrity checking in place because if this is a multiuser system, that would be a fantastic security hole for someone to exploit if they knew it existed.

eNtoS 06-13-2006 09:11 AM

Oh that's neat :D Thx!

Concerning security...
To make a long story short, Im installing port knocking, but it does not have some features i want, so i have to write them myself... and that line will be part of a script where the preceding line retrieves an ip(source ip for the port forward rule) from a server on the internet and puts it in /path/to/file.txt (to follow on from your example)(ie wget -q mysrv.com/myfile)

Having said that... what should i put inside "$( )" for it to be replaced by the contents of www.mysrv.com/myfile ?
I tried "wget -q -O www.mysrv.com/myfile" but it does not work....

cs-cam 06-13-2006 05:49 PM

Code:

lynx -dump http://www.example.com/myfile
I'm sure you could do it with wget but I never looked how because lynx is so damn easy :)


All times are GMT -5. The time now is 07:19 AM.