Results 1 to 5 of 5

Thread: Can someone code me a small app that...

  1. #1
    Lieutenant Commander pagemap's Avatar
    Join Date
    Sep 2001
    Location
    Madison, WI
    Posts
    924

    Can someone code me a small app that...

    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!!!
    Got|Apex Senior Inexperienced Poster
    S.I.P.

  2. #2

    VB tim$

    VB trim$(string) works quite well.

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

  3. #3
    Lieutenant Commander pagemap's Avatar
    Join Date
    Sep 2001
    Location
    Madison, WI
    Posts
    924
    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.
    Got|Apex Senior Inexperienced Poster
    S.I.P.

  4. #4
    Commander Paymaster's Avatar
    Join Date
    Jul 2000
    Location
    Middle Earth
    Posts
    1,367
    I assume that this is on a PC...

    Install PERL from cpan.org

    Code:
    $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

    Code:
    perl -pie 's/^/no /;' <input file>
    But I thought that the full code might make more sense to a non-programmer.
    "eh, take your opinion and shove it... somewhere else other than this thread" ~ welfareloser

  5. #5
    Fleet Admiral hapoo's Avatar
    Join Date
    Jan 2000
    Location
    742 Evergreen Terrace, Springfield USA
    Posts
    9,276
    just compile that code into an exe for him

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •