Jump to content

new2code

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

About new2code

  • Birthday 11/07/1985

Profile Information

  • Gender
    Male
  • Location
    Canada

new2code's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. it doesn't. is there any other way this can be done? at least a method where the input text is stored in temp file and the file is assigned to variables so I can pass it through the command. I'm sorry if I'm asking something hard. any help is much appreciated. Thank you.
  2. Hi Im not sure the xml_builder.pl has a the option to accept stlin. and sorry about my the Java script misunderstanding . what I was thinking is to have a text box when I submit some text through it creates a text file and that text file is then ran through the xml_builder.pl using exec and the resulting file is again run through the jar file and the final image to be displayed in the browser. is this possible? Text box ---> textfile ---> execute perl script on text --- xml output ---> java ---> image
  3. Hi Everyone, I have a perl script and a java sript. I need to run the perl script first and parser a txt file and then run a java scrip to convert that file to a png. here is an example of the script I will have to run. both this command on the terminal to get an output file (output.png) 1. perl xml_builder.pl -sequence /sequences.txt -output /data/done_sequesnces.xml -tick_density 0.7 2. java -jar view.jar -i /data/done_sequesnces.xml -o /data/output.png -f png I have to run both this command on the terminal to get an output file (output.png) is there a way I can and html or a php page that instead of using a text file (sequences.txt) I can past the text in a text box or if not upload the txt file. And when pressed submit it will run the Perl script and the Java script to output the png file to a folder? I know its seesm to be allot to ask, but I know there are excellent programmers here who can do wonders. I am at a very basic level of programming. Any Help Will be Much appreciated. Thank you in advance.
  4. mjdamato thank you so much. I'm so bad at this I created 2 file to try it out and finaly realized heeds one php with the html code in it. It works fine Thank you. you guys are awesome.!
  5. Hi I have a php scrip that looks for a sring and removes everything else in a file just saving the whole line with that string.($key = "C " as you can see its actually repeating the same thing and filtering few stings. I was wondering is there a way I can make it ask for the string before it proceeds ans a user input? I know it might not even make much sence. I am very new for php or any programming language but learning. here is the code: <?php $key = "C "; // <--------- [b]to prompt to ask for this[/b] //load file into $fc array $fc=file("input.txt"); //open same file and use "w" to clear file $f=fopen("output.txt","w"); //loop through array using foreach foreach($fc as $line) { if (strstr($line,$key)) //look for $key in each line -adding ! if (!strstr($line,$key)) does the opposite it will delete everything else than A fputs($f,$line); //place $line back in file } fclose($f); $key2 = "C 0."; //load file into $fc array $fe=file("output.txt"); //open same file and use "w" to clear file $fi=fopen("final.txt","w"); //loop through array using foreach foreach($fe as $line2) { if (!strstr($line2,$key2)) //look for $key in each line -adding ! if (!strstr($line,$key)) does the opposite it will delete everything else than A fputs($fi,$line2); //place $line back in file } fclose($fi); $key3 = "F "; //filters just this text at the begining of a line //load file into $fc array $fc3=file("input.txt"); //open same file and use "w" to clear file $f3=fopen("output2.txt","w"); //loop through array using foreach foreach($fc3 as $line3) { if (strstr($line3,$key3)) //look for $key in each line -adding ! if (!strstr($line,$key)) does the opposite it will delete everything else than A fputs($f3,$line3); //place $line back in file } fclose($f3); $key4 = "F 0."; //load file into $fc array $fc4=file("output2.txt"); //open same file and use "w" to clear file $f4=fopen("final2.txt","w"); //loop through array using foreach foreach($fc4 as $line4) { if (!strstr($line4,$key4)) //look for $key in each line -adding ! if (!strstr($line,$key)) does the opposite it will delete everything else than A fputs($f4,$line4); //place $line back in file } fclose($f4); ?> Thank you so much in advance.
  6. Hi! I need php script that would open a text file, look for a string i specified, and if it finds that string, it will take that entire line in the text file and write it to a file, or atleast print it on screen. I'm new to php. Any help would be appreciated. for example if i have A 147431 144303 141872 144785 142446 144562 141555 145865 143143 145916 B 143684 143123 143514 143658 142608 141691 142373 141876 142263 138982 C 142396 141927 139827 140461 138406 142819 145473 140561 142327 141502 A 141651 142869 141524 141891 143055 138903 143952 142527 139659 141755 E 141000 143583 142330 140254 139120 139912 138813 139317 140466 140644 A 143092 138276 141201 145585 144741 140144 142902 138926 145236 140625 G 143110 141567 144070 145861 140292 138486 151661 138287 137014 140431 H 139878 140626 142356 141335 140446 137627 141406 140058 139457 138107 I want all the lines starting with A(tab) to be written to another file or print it on screen. I know this code below does smiler thing but it deletes the whole line if it has an "A" but I need something which will look for A (tab space) beginning of a line and copy the whole line to a file. <?php $key = "A"; //looks for A //load file into $fc array $fc=file("some.txt"); //open same file and use "w" to clear file $f=fopen("some.txt","w"); //loop through array using foreach foreach($fc as $line) { if (!strstr($line,$key)) //look for $key in each line fputs($f,$line); //place $line back in file } fclose($f); ?> Thank you so much for all in advance, this forum is great.
  7. I know the subject heading might be misleading, However, Im new to php and english. here is my question I have a script which takes a file and breaks in to smaller files with filenames part.date and a sequential integer (1,2,3,4 ....) NVISION-part.01-01-2010-1.txt NVISION-part.01-01-2010-2.txt NVISION-part.01-01-2010-2.txt I have several input files and every time I have a new input file it will start naming the out put files from 1,2,3 and so on. I was wondering is there a way I can have a prompt at the beginning so I can say which number to start from when renaming the files?. code: <?php class filesplit{ /** * Constructor * @access protected */ function filesplit(){ } /** * File to split * @access private * @var string **/ var $_source = 'logs.txt'; /** * * @access public * @return string **/ function Getsource(){ return $this->_source; } /** * * @access public * @return void **/ function Setsource($newValue){ $this->_source = $newValue; } /** * how much lines per file * @access private * @var integer **/ var $_lines = 1000; /** * * @access public * @return integer **/ function Getlines(){ return $this->_lines; } /** * * @access public * @return void **/ function Setlines($newValue){ $this->_lines = $newValue; } /** * Folder to create splitted files with trail slash at end * @access private * @var string **/ var $_path = 'logs/'; /** * * @access public * @return string **/ function Getpath(){ return $this->_path; } /** * * @access public * @return void **/ function Setpath($newValue){ $this->_path = $newValue; } /** * filesplit::configure() Configure the class * * @param string $source * @param string $path * @param string $lines * @return **/ function configure($source = "",$path = "",$lines = ""){ if ($source != "") { $this->Setsource($source); } if ($path!="") { $this->Setpath($path); } if ($lines!="") { $this->Setlines($lines); } } /** * Run the FileSplit process * @access public * @return void **/ function run(){ $i=0; $j=1; $date = date("m-d-y"); unset($buffer); $handle = @fopen ($this->Getsource(), "r"); while (!feof ($handle)) { $buffer .= @fgets($handle, 4096); $i++; if ($i >= $this->_lines) { $fname = $this->Getpath()."NVISION-part.$date.$j.txt"; if (!$fhandle = @fopen($fname, 'w')) { print "Cannot open file ($fname)"; exit; } if (!@fwrite($fhandle, $buffer)) { print "Cannot write to file ($fname)"; exit; } fclose($fhandle); unset($buffer,$i); $j++; } } if (isset($buffer)) { $fname = $this->Getpath()."NVISION-part.$date.$j.txt"; if (!$fhandle = @fopen($fname, 'w')) { print "Cannot open file ($fname)"; exit; } if (!@fwrite($fhandle, $buffer)) { print "Cannot write to file ($fname)"; exit; } fclose($fhandle); unset($buffer,$i); } fclose ($handle); } /** * Delete all generated part files * */ function delete(){ $d = dir($this->Getpath()); while (false !== ($entry = $d->read())) { if (ereg("^NVISION-part",$entry)) { unlink($this->Getpath()."$entry"); } } $d->close(); return; } } ?>
  8. Thank you all. teamatomic! your script works fine, I cant believe I couldent figure this out. salathe, one line ! Wow! thank you. you guys are geniuses. works perfectly. I'm at a very basic level trying to learn PHP.
  9. Hi Im very new to php. I want to open a file (*.txt) and check for all the blank lines and remove them. and save it as the same file or a new file. I know this can be done using regex. although, I cant seemt to implement regex within a php file. <?php $file='logz.txt'; $fe = @fopen("$file", "w"); $fe = preg_replace('^\r?\n','',$fe); fclose($fe); ?> this is what I have, (it might be wrong) but it does not change anything in the logz.txt I will very greatfull if someone can help me out.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.