Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder jfreak53's Avatar
    Join Date
    May 2004
    Location
    Guatemala
    Posts
    477
    Thanks
    19
    Thanked 10 Times in 10 Posts

    Regex to last line in file usermin

    Ok I need some perl geniuses out there for a quick help. I had this module made for me in Perl for usermin, it works fine but the guy couldn't get it to work without looking for the following line in the config file:

    Code:
    rpcallowip=127.0.0.1
    Basically it adds IPs to a config file on a local system under the users directory. It works just fine, but I cannot have that line in the file, it breaks the program that uses the config file. Now I cannot get a hold of the coder anymore.

    So, here is the code that writes a new rpcallowip= line to the file:

    Code:
    $config=~ s/([\ \t]*#rpcallowip=127\.0\.0\.1(\s+rpcallowip=([\d\.]+|[\*]))*[\n|\r\n])/$1rpcallowip=$in{IPaddress}\n\n/;
    		open(CONF2,">/home/$remote_user/.bitcoin/bitcoin.conf");
    		flock(CONF2,2);
    		syswrite ( CONF2, $config, length $config);
    		flock(CONF2,FLOCK_UN);
    		close(CONF2);
    It all works just fine, problem is as you can see by the regex code it searches for that line above:

    Code:
    rpcallowip=127.0.0.1
    Then adds things below it. What I want it to do is add a new rpcallowip= line with the new IP to the end of the file, I don't want it to search for that line then add below it. I want it to add to the end of the file no matter what the new line.

    Any ideas? Any help? I am lost I am not a Perl guy and I have been racking my brain and don't even know where to start

    Thanks guys.
    "FORTRAN is not a language. It's a way of turning a multi-million dollar mainframe, into a $50 programmable scientific calculator."
    http://www.microfastcat.com -- FastCat Software, the fastest software on the NET!
    http://www.microthosting.com -- Free reseller web hosting, Hosting, VPS, FREE SMALL HOSTING!!!
    http://www.microtronix-tech.com -- Web design and programming

  • #2
    Regular Coder jfreak53's Avatar
    Join Date
    May 2004
    Location
    Guatemala
    Posts
    477
    Thanks
    19
    Thanked 10 Times in 10 Posts
    Nevermind! Finally after a few days I got it ha ha this always happen, I post here and I get it ha ha

    It's probably not the correct way to do it but it works for me ha ha

    Code:
    $config.= "\n"."rpcallowip=".$in{IPaddress}."\r";
    Thanks.
    "FORTRAN is not a language. It's a way of turning a multi-million dollar mainframe, into a $50 programmable scientific calculator."
    http://www.microfastcat.com -- FastCat Software, the fastest software on the NET!
    http://www.microthosting.com -- Free reseller web hosting, Hosting, VPS, FREE SMALL HOSTING!!!
    http://www.microtronix-tech.com -- Web design and programming


  •  

    Posting Permissions

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