Probably not going to happen tonight, something came up. I'll see what I can do.
sudo rm -rf /
Thanks, appreciate it.
Please get back to this first chance you get.
Thanks in advance,
Panarchy
Haven't tested this, but I think it'll work.
Code:#!/usr/bin/env perl use strict; my (@iplist,$template,$currip) = ((),'',''); #open ip list file open(IPFILE,"<iplist.csv") or die "Failed to open IP list file."; #read all lines into array my @ipfile,$i = ((),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. $iplist[$i] =~ split(/^*,(*)$/,$_); ++$i; } #close ip list file close(IPFILE); #open template file open(CPPTEMPLATE,"<cpptemplate.cpp") or die "Failed to open template file."; #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"; #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.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); } #close template file close(CPPTEMPLATE); #exit 1;
sudo rm -rf /
Thanks for the code.
Unfortunately, it doesn't work
Please help me get it to work!Code:#!/usr/bin/env perl use strict; my (@iplist,$template,$currip) = ((),'',''); #open ip list file open(IPFILE,"<iplist.csv") or die "Failed to open IP list file."; #read all lines into array my @ipfile,$i = ((),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. $iplist[$i] =~ split(/^*,(*)$/,$_); ++$i; } #close ip list file close(IPFILE); #open template file open(CPPTEMPLATE,"<VNC.cpp") or die "Failed to open template file."; #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"; #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.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); } #close template file close(CPPTEMPLATE); #should the above text 'CPPTEMPLATE' be replaced with VNC.cpp? #exit 1;
Thanks in advance,
Panarchy
That would be because I'm an idiot...
Code:#!/usr/bin/env perl use strict; my (@iplist,$template,$hostname,$currip) = ((),'','',''); #open ip list file open(IPFILE,"<iplist.csv") or die "Failed to open IP list file."; #read all lines into array my (@ipfile,$i) = ((),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. ($hostname,$iplist[$i]) =~ split(/,/); chomp($iplist[$i]); ++$i; } #close ip list file close(IPFILE); #open template file open(CPPTEMPLATE,"<VNC.cpp") or die "Failed to open template file."; #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"; #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.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); } #close template file close(CPPTEMPLATE); #should the above text 'CPPTEMPLATE' be replaced with VNC.cpp? #exit 1;
sudo rm -rf /
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;
We're almost there... Please help me complete this!Code:cl /clr "super.cpp" link super-resource.res main.obj /out:"%name%".exe
Thanks in advance,
Panarchy
Dude, I'd love to help, but I have a full-time job. I think the rest is rather straight-forward enough for you to figure out with the Perl tutorials below:
Starting Perl (Good but out of date)
PerlTutorial.org (Great for people who already know how to program)
sudo rm -rf /
you just need to call the compiler with the correct arguments then start the loop again
Dargueta: As do I!
Well, I'll read through the tutorial, and come back here if I need more help.
Once I've worked it out, I'll post the completed code here.
Thanks for your help Dargueta,
Panarchy
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks