LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 06-12-2002, 12:45 AM   #1
robeb
Member
 
Registered: May 2002
Posts: 113

Rep: Reputation: 15
Add lines of code to files from command line


I would like to be able to add lines of code to files from the command line. For example, if I choose to deny a host in my firewall script I would want to add "iptables -A INPUT -s X.X.X.X -j DROP" from the command line. I tried adding the line of code with "cat [code] >> firewall.script" but got errors. How can I do this?

- Thank you
 
Old 06-12-2002, 03:04 AM   #2
Mik
Guru
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Gentoo + LFS
Posts: 1,316

Rep: Reputation: 46
Well unless you've got the command in a file then you'd probably be better off using echo instead of cat.
Ex:

echo "iptables newcommand" >> firewallscript


But with that you are only adding the command to the firewall script and not enabling the rule. There are two things you can do. Either run the code and add it to your firewallscript. Or you can just run the code to add the new rule. And then there is a command in iptables to create a script file of all the current rules being used. You can use this as your new firewall script. Don't remember the command by memory though but it shouldn't be too hard to find in the docs.
 
Old 06-12-2002, 03:54 AM   #3
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,121

Rep: Reputation: 121Reputation: 121
Couldn't you use sed and awk to achieve this... ?? At least you could use sed at the most...
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How To Add user in Fedora Core 4 using the Command Line Interface regnox Linux - Newbie 9 08-22-2005 12:30 AM
posting code from command line frankie_DJ Linux - Newbie 3 08-09-2005 08:51 AM
Shell Scripting: How to pick lines out of files by line number. Louie55 Programming 3 03-22-2005 06:18 PM
C program code to run a Linux command line Linh Programming 10 06-11-2003 01:59 PM
how to add icon with the command line jonsharland Linux - General 1 10-17-2002 03:59 AM


All times are GMT -5. The time now is 09:42 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration