Closed Thread
Page 5 of 7 FirstFirst ... 34567 LastLast
Results 41 to 50 of 70

Thread: HELP: Script to gather IP Address from .RDP then compile to .exe for VNC

  1. #41
    Panarchy is offline Programming Professional
    Join Date
    Nov 2007
    Posts
    259
    Rep Power
    0

    Re: HELP: Script to gather IP Address from .RDP then compile to .exe for VNC

    Oh!!!

    Thanks, I'll give it a go.

    Hopefully this line doesn't need correcting;

    Code:
    #open template file
    open(CPPTEMPLATE,"<VNC.cpp>") or die "Failed to open template file.";

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #42
    Panarchy is offline Programming Professional
    Join Date
    Nov 2007
    Posts
    259
    Rep Power
    0

    Re: HELP: Script to gather IP Address from .RDP then compile to .exe for VNC

    Unfortunately the script still doesn't work.

    Quote Originally Posted by Panarchy View Post
    Thanks, however there are still some missing features.

    To be clearer, I have listed them in 4 steps;

    Step 1. Process IP Address from CSV
    Step 2. Process Name from CSV
    Step 3. Input IP Address into VNC.cpp
    Step 4. Compile with Name

    It seems that Step 4 has been left out... please include it.

    To confirm, Step 4 should correspond the following;
    Code:
    cl /clr "super.cpp"
    link super-resource.res main.obj /out:"%name%".exe
    Please help complete the script.

    Thanks in advance,

    Panarchy
    Last edited by Panarchy; 07-29-2009 at 08:46 PM.

  4. #43
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: HELP: Script to gather IP Address from .RDP then compile to .exe for VNC

    Change this:
    Code:
    open(CPPTEMPLATE,"<VNC.cpp>") or die "Failed to open template file.";
    To this:
    Code:
    open(CPPTEMPLATE,"<VNC.cpp") or die "Failed to open template file.";
    ...and change this:
    Code:
    $template =~ /__PUTIPHERE__/$currip/g;
    to this:
    Code:
    $template =~ s/__PUTIPHERE__/$currip/g;
    sudo rm -rf /

  5. #44
    Panarchy is offline Programming Professional
    Join Date
    Nov 2007
    Posts
    259
    Rep Power
    0

    Re: HELP: Script to gather IP Address from .RDP then compile to .exe for VNC

    Thanks.

    The script now runs successfully... however...

    It doesn't work. This may make things a little clearer;



    Please complete this script.

    Thanks in advance,

    Panarchy

    EDIT: Althought the screenshot doesn't show it, I ran the script in between. It didn't say 'ran successfully' or anything like that, but didn't give errors.

  6. #45
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: HELP: Script to gather IP Address from .RDP then compile to .exe for VNC

    I'm confused.
    sudo rm -rf /

  7. #46
    Panarchy is offline Programming Professional
    Join Date
    Nov 2007
    Posts
    259
    Rep Power
    0

    Lightbulb Re: HELP: Script to gather IP Address from .RDP then compile to .exe for VNC

    Quote Originally Posted by Panarchy View Post
    Thanks, however there are still some missing features.

    To be clearer, I have listed them in 4 steps;

    Step 1. Process IP Address from CSV
    Step 2. Process Name from CSV
    Step 3. Input IP Address into VNC.cpp
    Step 4. Compile with Name

    It seems that Step 4 has been left out... please include it.

    To confirm, Step 4 should correspond the following;
    Code:
    cl /clr "super.cpp"
    link super-resource.res main.obj /out:"%name%".exe
    Thanks in advance,

    Panarchy

  8. #47
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: HELP: Script to gather IP Address from .RDP then compile to .exe for VNC

    Code:
    #!/usr/bin/env perl
    
    use strict;
    use warnings;
    use POSIX;
    
    #declare whitespace-trimming function defined later
    sub trim($);
    
    my (@iplist,@hostlist,$template,$hostname,$currip,$currhost) = ((),(),'','','','');
    
    #open ip list file
    open(IPFILE,"<iplist.csv") or die "Failed to open IP list file.";
    #read all lines into array
    my (@ipfile,$i,$total) = ((),0,0);
    @ipfile = <IPFILE>;
    #for each line in the ip file...
    foreach(@ipfile)
    {
    	#strip leading and trailing spaces off the line
    	chomp($_);
    	#use regular expressions to pull the 
    	#ip address from the line. I have to
    	#check to see if the regex will do
    	#what it's supposed to.
    	($hostlist[$i],$iplist[$i]) =~ split(/,/);
            #remove leading and trailing whitespace
            $hostlist[$i] = trim($hostlist[$i]);
            $iplist[$i] = trim($iplist[$i]);
    	++$i;
            ++$total;
    }
    #close ip list file
    close(IPFILE);
    
    #open template file
    open(CPPTEMPLATE,"<VNC.cpp") or die "Failed to open template file.";
    
    #for each ip address in the list...
    for($i = 0; $i < $total; ++$i)
    {
        #load entire file into single string...
        #undefine end-of-record variable, which is \n by default. this will result
        #in the file being divided up into an array of lines instead of one single
        #string like we want.
        undef $/;
    
        #read the file into $template.
        $template = <VNC.cpp>;
    
        #reset $/ to avoid problems.
        $/ = "\n";
    
        #get the current ip & host
        $currip = $iplist[$i];
        $currhost = $hostlist[$i];
        #open the output file
        open(CPPOUT,">$currhost.cpp") or die "Failed to open $currhost.cpp for writing.";
        #replace all instances of __PUTIPHERE__ in the template file with the
        #current ip address.
        $template =~ /__PUTIPHERE__/$currip/g;
        #print the result to the output file.
        print CPPOUT $template;
        #close the output file
        close(CPPOUT);
        #compile
        `cl /clr $currhost.cpp`;
        `link super-resource.res main.obj /out:$currhost.exe`;
        #rewind to beginning of template file to read again
        seek(CPPTEMPLATE,0,SEEK_SET);
    }
    
    #close template file
    close(CPPTEMPLATE);
    
    #exit
    1;
    
    ####
    sub trim($)
    {
        my $str = shift;
        $str =~ s/^\s+//;
        $str =~ s/\s+$//;
        return $str;
    }
    Last edited by dargueta; 07-29-2009 at 10:25 PM.
    sudo rm -rf /

  9. #48
    Panarchy is offline Programming Professional
    Join Date
    Nov 2007
    Posts
    259
    Rep Power
    0

    Re: HELP: Script to gather IP Address from .RDP then compile to .exe for VNC

    Thanks a heap!

    Looks pretty much complete now!

    Hate to disappoint you, but I'm getting this error;



    Please fix!

    I feel that it's very close to completion!

    Thanks,

    Panarchy

  10. #49
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: HELP: Script to gather IP Address from .RDP then compile to .exe for VNC

    Well, for starters you didn't make the fix I mentioned earlier with prefixing 's' to the regex. And it looks like you're running a more recent version of Perl than I am. My fail.

    Code:
    #!/usr/bin/env perl
    
    use strict;
    use warnings;
    use POSIX;
    
    #declare whitespace-trimming function defined later
    sub trim($);
    
    my (@iplist,@hostlist,$template,$hostname,$currip,$currhost) = ((),(),'','','','');
    
    #open ip list file
    open(IPFILE,"<iplist.csv") or die "Failed to open IP list file.";
    #read all lines into array
    my (@ipfile,$i,$total) = ((),0,0);
    @ipfile = <IPFILE>;
    #for each line in the ip file...
    foreach(@ipfile)
    {
    	#strip leading and trailing spaces off the line
    	chomp($_);
    	#use regular expressions to pull the 
    	#ip address from the line. I have to
    	#check to see if the regex will do
    	#what it's supposed to.
    	($hostlist[$i],$iplist[$i]) =~ split(/,/,$_);
            #remove leading and trailing whitespace
            $hostlist[$i] = trim($hostlist[$i]);
            $iplist[$i] = trim($iplist[$i]);
    	++$i;
            ++$total;
    }
    #close ip list file
    close(IPFILE);
    
    #open template file
    open(CPPTEMPLATE,"<VNC.cpp") or die "Failed to open template file.";
    
    #for each ip address in the list...
    for($i = 0; $i < $total; ++$i)
    {
        #load entire file into single string...
        #undefine end-of-record variable, which is \n by default. this will result
        #in the file being divided up into an array of lines instead of one single
        #string like we want.
        undef $/;
    
        #read the file into $template.
        $template = <VNC.cpp>;
    
        #reset $/ to avoid problems.
        $/ = "\n";
    
        #get the current ip & host
        $currip = $iplist[$i];
        $currhost = $hostlist[$i];
        #open the output file
        open(CPPOUT,">$currhost.cpp") or die "Failed to open $currhost.cpp for writing.";
        #replace all instances of __PUTIPHERE__ in the template file with the
        #current ip address.
        $template =~ s/__PUTIPHERE__/$currip/g;
        #print the result to the output file.
        print CPPOUT $template;
        #close the output file
        close(CPPOUT);
        #compile
        `cl /clr $currhost.cpp`;
        `link super-resource.res main.obj /out:$currhost.exe`;
        #rewind to beginning of template file to read again
        seek(CPPTEMPLATE,0,SEEK_SET);
    }
    
    #close template file
    close(CPPTEMPLATE);
    
    #exit
    1;
    
    ####
    sub trim($)
    {
        my $str = shift;
        $str =~ s/^\s+//;
        $str =~ s/\s+$//;
        return $str;
    }
    sudo rm -rf /

  11. #50
    Panarchy is offline Programming Professional
    Join Date
    Nov 2007
    Posts
    259
    Rep Power
    0

    Re: HELP: Script to gather IP Address from .RDP then compile to .exe for VNC

    Hi

    Thanks, from the looks of things, it'll work now.

    I'll try tomorrow, as I don't have the script, scripting engine, csv file or Visual Studio with me at the moment.

    Thanks once again,

    Panarchy

Closed Thread
Page 5 of 7 FirstFirst ... 34567 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 5
    Last Post: 04-30-2011, 04:12 PM
  2. [HELP] convert Perl script to Bash shell script
    By Egypte in forum Linux Programming and Scripting
    Replies: 2
    Last Post: 04-24-2011, 05:37 PM
  3. Can't Compile
    By tedmp0816 in forum C and C++
    Replies: 4
    Last Post: 10-20-2009, 01:00 AM
  4. PHP: Gather ALL Post Variables
    By phpforfun in forum PHP Development
    Replies: 7
    Last Post: 01-30-2009, 02:34 PM

Tags for this Thread

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