Closed Thread
Page 6 of 7 FirstFirst ... 4567 LastLast
Results 51 to 60 of 70

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

  1. #51
    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

    Unfortunately, the script still doesn't work.

    A lot of output, so I've attached it into a logfile within this post.

    Please take a look at it. If you'd like me to use a different version of Perl, please tell me which version.

    Thanks in advance,

    Panarchy
    Attached Files Attached Files

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #52
    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

    1) The deprecated split error was my fault, I forgot to change =~ back to =
    2) You changed the <VNC.cpp> back. It should be <CPPTEMPLATE>.
    3) I don't understand why some variables aren't getting initialized. I did it the long way (now it works), but it used to the other way before. Dunno, maybe they changed it in the newest release of Perl, which I updated to.

    I don't know if this'll work because I don't have the compiler or linker installed on my system, but the rest seems to work just fine.

    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);
    @ipfile = <IPFILE>;
    #for each line in the ip file...
    $i = 0;
    $total = 0;
    foreach(@ipfile)
    {
    	#strip leading and trailing spaces off the line
    	my $thisline = $_;
    	chomp($thisline);
    	#use regular expressions to pull the ip address from the line.
    	($currhost,$currip) = split(/\,/,$thisline);
    
        #remove leading and trailing whitespace
        $hostlist[$i] = trim($currhost);
        $iplist[$i] = trim($currip);
    	++$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 = <CPPTEMPLATE>;
    
        #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(@_);
        if(not defined $str){ return ''; }
        $str =~ s/^\s+//;
        $str =~ s/\s+$//;
        return $str;
    }
    sudo rm -rf /

  4. #53
    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 dargueta, really appreciate it.

    I'll test it on Monday.

    Panarchy

    PS: I didn't change the script at all?

  5. #54
    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 think you changed it and then uploaded the unchanged version or something, I dunno.
    sudo rm -rf /

  6. #55
    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

    Nope...

    Well anyway, pretty sure this latest script of yours will work, so I'll just give that a go on Monday.

  7. #56
    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

    I've got 300+ .cpp files now, with the correct names. However, when opening the .cpp files, the IP Address didn't go through

    I've also got about half that in .exe.manifest & .obj files.

    Nothing's been completed compiled.

    Please fix the script.

    Thanks in advance,

    Panarchy

  8. #57
    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

    The IP addresses worked fine for me...are you sure you spelled the replacement token right?
    sudo rm -rf /

  9. #58
    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

    I kept the everything identical to your script.

    In fact, I changed my files [CSV & the entire C++ project] to reflect the names you used.

    I ran the script from the correct Command-Prompt.

  10. #59
    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

    Weird. It worked just fine for me. What I meant was, did you put the token __PUTIPHERE__ everywhere you needed the IP address in your template file, and leave __PUTIPHERE__ alone in the script? You shouldn't need to touch anything in the script except the file names (leave the < before the file name, it means "open for reading"), and the two compile/link commands. (Leave the backticks in, though.)


    EDIT: Looking at your compile/link commands, I think you might have to change main.obj to $currhost.obj. I'm not sure, as I don't know how your compiler works.
    Last edited by dargueta; 08-05-2009 at 05:09 AM. Reason: Forgot info
    sudo rm -rf /

  11. #60
    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

    ^Hmm... I'll try with that tomorrow.

    Thanks

    Panarchy

    BTW: I'm just using the 90-day trial of Visual Studio 2008 Professional. But there's also the express edition [free], which uses, what I believe to be, the same compiler. Perhaps if we still can't get it to work after this, you could install it?

Closed Thread
Page 6 of 7 FirstFirst ... 4567 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