PDA

View Full Version : Can someone code me a small app that...



pagemap
04-25-2002, 08:41 PM
Puts a no[space] before all lines of a text file. Say I have the following access lists on my router:

access-list 102 permit ip 192.168.1.0 0.0.0.255 any
access-list 111 permit tcp any any eq ftp
access-list 111 permit tcp any any eq www
access-list 111 permit tcp any any eq 4000

I want to put a no in front of all these access lists to remove them from the router, so I want a small application that will open the text file and modify the text file so that it looks like this after the program completes:

no access-list 102 permit ip 192.168.1.0 0.0.0.255 any
no access-list 111 permit tcp any any eq ftp
no access-list 111 permit tcp any any eq www
no access-list 111 permit tcp any any eq 4000

Thanks!!!

purduephotog
04-25-2002, 09:03 PM
VB trim$(string) works quite well.

i might have time at work if I'm so bored- can you compile?

pagemap
04-25-2002, 09:06 PM
I might be able to. The most I have compiled is a small VB program, if it requires any more than this I would have to say I dont know how to compile.

Paymaster
04-26-2002, 04:48 PM
I assume that this is on a PC...

Install PERL from cpan.org



$in = shift (@_);
$out = shift (@_);
open (IN, "$in") || die "Cannot open input file\n";
open (OUT, ">$out") || die "Cannot open output file\n";
while (<IN>) {
print OUT "no $_";
}
close (IN);
close (OUT);
exit (0);

Save the above as a file.

Then type "perl <program> <input file> <output file>"

If you were really geeky, you would use



perl -pie 's/^/no /;' <input file>

But I thought that the full code might make more sense to a non-programmer.

hapoo
04-29-2002, 09:59 PM
just compile that code into an exe for him