Thanks for you suggestions ikonia.
I have no idea how the .csv file is stuctured. Once he has given me the .csv file, I'll post an [edited] copy of it here.
ikonia: The 2nd method you mentioned, how would I put the name in the /out: parameter, automatically?
Also, speed doesn't matter. Even if it takes 24 hours to complete, well whatever.
I'll try and get the .csv file again, sorry for the wait.
Panarchy
CSV - Comma-delimited text file. Basically one record per line, fields are separated by commas. You could use a printf() call for the /OUT: parameter.
Thanks, though I would still like everyone to get a look at the CSV file, to confirm that what you've been suggesting is possible.
Supposing it's something like;
255.255.255.255, Panarchy
124.323.125.235, SandMan
...
Could you please give me an example of how the code to input the data into the .cpp file, then compile it with the name look?
Thanks in advance,
Panarchy
Same thing. You put a token in the template CPP file that doesn't appear anywhere else, then you do a string replace.
Can I do a per-line replacement?
As I'm thinking that would be better... I can put the IP Address on a line of it's own.
Also, could I please have an example of how the end-code should look?
Thanks in advance,
Panarchy
No need to. Prepare to be amazed by the power of Perl.
Code:#!/usr/bin/env perl use strict; my (@iplist,@template,$currip,@outln) = ((),(),'','') #fill iplist with ip's here #open template file open(CPPTEMPLATE,"<cpptemplate.cpp") or die "Failed to open template file."; #load entire file into array @template = <CPPTEMPLATE>; #for each ip address in the list.... foreach(@iplist) { #get the current ip $currip = $_; #open the output file open(CPPOUT,">$currip.cpp") or die "Failed to open $currip for writing."; #for every line in the template file... foreach(@template) { #replace all occurrences of __PUTIPHERE__ with the current ip $outln =~ /__PUTIPHERE__/$currip/g; #write it out to the output file print CPPOUT $outln } #close the output file close(CPPOUT); } #close template file close(CPPTEMPLATE); #exit 0;
sudo rm -rf /
now that's some tidy perl, slick
*insert applause emoticon here*
Thanks dargueta. To mix good news with good news, I received the .csv file today!
Two quick questions;Your code is beautiful. Please use your talent to add the missing capabilities listed above.
- How do I concatenate the .csv file into the Perl script? You did declare @iplist, however I don't understand how you'd like it sorted. Also, the names...
- The compiler options/commands, where do they fit in?
Code:cl /clr "super.cpp" link super-resouce.res main.obj /out:"%name%".exe
Thanks once again,
Panarchy
Post the CSV so I can see what the fields are like, then I'll write it up tonight. Should take me all of five minutes, I think.
sudo rm -rf /
Excellent, I'll be looking forward to the end product.
Book1.csv
Also, unsure of why I am yet to post it, but here are the project files for the VNC Authentication;
Code::Blocks project: VNC.zip
Visual Studio 2008 project: VNC.zip
Thanks for all your help, will be looking forward to tonight [in your timezone!]
Panarchy
Last edited by Panarchy; 06-09-2009 at 06:42 PM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks