由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 简单的perl问题
相关主题
弱问perl写网页buffer问题一个 perl 的 print 的初级问题
想实现一个简单的script language,用perl好做么?perl cgi中调用C可执行程序为什么在html中不显示? (转载)
Perl里面$,@,#等字符问题Perl 6 改动很大很恶心
请看看这个Perl random sampling code 有什么问题,Help -- How to output error messages to a file for scripts called by system calls???
a question of perlcmake coeblock求教
perl question: can I have a key of hash to be请教一个makefile 小问题
50伪币:请教perl代码差错的问题!多谢啦!关于perl和linux shell script的书最经典有哪些? (转载)
求教一个perl问题一个python script同时写一万多个文本文件
相关话题的讨论汇总
话题: dt话题: php话题: my话题: interval话题: t1
进入Programming版参与讨论
1 (共1页)
c**t
发帖数: 2744
1
下面这一段code在W2k3下运行一段时间就停止了(没有新的timestamp打印到stdout),
可能是怎么回事?
#!C:\perl\bin -w
use strict;
my ($t1, $t2, $dt);
my $DIR = 'C:\Scripts';
my $PHP = 'C:\PHP\php.exe';
my $SRC = 'getData.php';
my $INTERVAL = 3;
chdir($DIR);
my $i = 0;
while(1)
{
$t1 = time;
system($PHP, $SRC);
$t2 = time;
$dt = ($INTERVAL * 60) - ($t2 - $t1);
if($dt > 0)
{
print "[", scalar(localtime(time)), "] Sleeping $dt seconds\
n";
sleep( $dt );
t****t
发帖数: 6806
2
maybe system() hangs?

【在 c**t 的大作中提到】
: 下面这一段code在W2k3下运行一段时间就停止了(没有新的timestamp打印到stdout),
: 可能是怎么回事?
: #!C:\perl\bin -w
: use strict;
: my ($t1, $t2, $dt);
: my $DIR = 'C:\Scripts';
: my $PHP = 'C:\PHP\php.exe';
: my $SRC = 'getData.php';
: my $INTERVAL = 3;
: chdir($DIR);

w******p
发帖数: 166
3
my guess is here:
$dt = ($INTERVAL * 60) - ($t2 - $t1);
when it happens that $dt < 0
then sleep($dt) would convert the negative $dt into a really big one and it'
ll sleep there like forever, add this line
$dt = 1 if $dt < 1;
c**t
发帖数: 2744
4
the sleep is inside if( $dt > 0) block, shall we still check $dt?

it'

【在 w******p 的大作中提到】
: my guess is here:
: $dt = ($INTERVAL * 60) - ($t2 - $t1);
: when it happens that $dt < 0
: then sleep($dt) would convert the negative $dt into a really big one and it'
: ll sleep there like forever, add this line
: $dt = 1 if $dt < 1;

c**t
发帖数: 2744
5
Could be php script issue. The system call never came back. I added set_time
_limit in the php script, it seems worked.

my guess is here:
$dt = ($INTERVAL * 60) - ($t2 - $t1);
when it happens that $dt < 0
then sleep($dt) would convert the negative $dt into a really big one and it'
ll sleep there like forever, add this line
$dt = 1 if $dt < 1;

【在 w******p 的大作中提到】
: my guess is here:
: $dt = ($INTERVAL * 60) - ($t2 - $t1);
: when it happens that $dt < 0
: then sleep($dt) would convert the negative $dt into a really big one and it'
: ll sleep there like forever, add this line
: $dt = 1 if $dt < 1;

1 (共1页)
进入Programming版参与讨论
相关主题
一个python script同时写一万多个文本文件a question of perl
Node已经成为enterprise的go-to technology了perl question: can I have a key of hash to be
有谁对bash script熟悉的,请教一个问题50伪币:请教perl代码差错的问题!多谢啦!
[转载] 在CGI程序中有何好方法返回HTML求教一个perl问题
弱问perl写网页buffer问题一个 perl 的 print 的初级问题
想实现一个简单的script language,用perl好做么?perl cgi中调用C可执行程序为什么在html中不显示? (转载)
Perl里面$,@,#等字符问题Perl 6 改动很大很恶心
请看看这个Perl random sampling code 有什么问题,Help -- How to output error messages to a file for scripts called by system calls???
相关话题的讨论汇总
话题: dt话题: php话题: my话题: interval话题: t1