It's hard to tell exactly what you mean when you refer to "shell command", particularly because you don't show us anything you've tried, but here's a simple Perl snippet that shows how to do what you want.
#!/usr/bin/perl
use strict;
use warnings;
open my $fh, '<', 'file.txt' or die "Can't open file: $!";
while ( my $line = <$fh> ){
chomp $line;
# do stuff
print "$line\n";
}
| [reply] [d/l] |
I am running a script to scan my website for vulnerabilities, when it finds them I want it to print the page, then continue, so it is running a while statement.
I don't run it in a browser, I run it in shell:
perl scanSite.cgi shell=1 dir=pathToStart
So the script runs for 1 hundred thousand scans, always looking for vulnerabilities and sleeping 1 second in between, I have it print a period every 1 minute so that I know it is still running and when it finds something that matches what I have it looking for on the page, it prints the url and what it found.
The problem is the print commands do not print anything, no periods or anything, but if I put a exit command in then it prints everything all at one time.
What I want it to do is print stuff as it comes across the print command and not wait until the script is done with everything and comes across the exit command.
Is there a perl command to have it print the output as it comes across it and not wait until the script is done?
Thanks,
Richard
| [reply] [d/l] |
| [reply] [d/l] |
| [reply] |