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 06-12-2006, 11:14 AM   #1
eNtoS
Member
 
Registered: Feb 2006
Distribution: slackware, ubuntu, knoppix, backtrack, debian
Posts: 35

Rep: Reputation: 15
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!
 
Old 06-12-2006, 06:15 PM   #2
cs-cam
Senior Member
 
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,544
Blog Entries: 4

Rep: Reputation: 57
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.
 
Old 06-13-2006, 09:11 AM   #3
eNtoS
Member
 
Registered: Feb 2006
Distribution: slackware, ubuntu, knoppix, backtrack, debian
Posts: 35

Original Poster
Rep: Reputation: 15
Oh that's neat 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....
 
Old 06-13-2006, 05:49 PM   #4
cs-cam
Senior Member
 
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,544
Blog Entries: 4

Rep: Reputation: 57
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
 
  


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
Running File in Its Own Command Window jagster936 Linux - Newbie 5 05-20-2006 12:27 AM
lack of file name after running 'ls - l' command jim656 Linux - Networking 1 02-15-2006 08:20 AM
Reading a file and running a command for each line. mijohnst Linux - General 11 08-22-2005 06:18 PM
kernel paramaters for install sh4d0w13 Debian 3 03-11-2005 02:32 PM
Setting up a static IP on linux box which obtains an IP via DHCP vxc69 Linux - Networking 19 07-13-2004 05:18 AM


All times are GMT -5. The time now is 05:49 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