Re: Perl loop

2007-12-15 Thread Chas. Owens
On Dec 15, 2007 12:22 PM, John W. Krahn <[EMAIL PROTECTED]> wrote: snip > > That depends on the version of C you are using. Given the lack of > > other syntax in this short program I cannot tell if it is K&R C, ANSI > > C, or C99. If he is using K&R C, that is a perfectly fine main > > definition

Re: Perl loop

2007-12-15 Thread John W . Krahn
On Saturday 15 December 2007 06:17, Chas. Owens wrote: > > On Dec 15, 2007 2:50 AM, John W. Krahn <[EMAIL PROTECTED]> wrote: > > > > $ cat test.c > > > #include > > > > > > main () { > > > > In C the main function returns an int so that is not compliant with > > the C standard[3]. It should be: >

Re: Perl loop

2007-12-15 Thread Chas. Owens
On Dec 15, 2007 2:50 AM, John W. Krahn <[EMAIL PROTECTED]> wrote: snip > > $ cat test.c > > #include > > > > main () { > > In C the main function returns an int so that is not compliant with the > C standard[3]. It should be: > > int main ( void ) { > > > printf("hello world"); snip That dep

Re: Perl loop

2007-12-15 Thread John W . Krahn
On Friday 14 December 2007 19:01, jeff pang wrote: > > --- "John W.Krahn" <[EMAIL PROTECTED]> wrote: > > > > No, you would have to do: > > > > if ( !system($touchcmd) && !system($chkstat) ) > > I have thought that, if the unix command's author doesn't return a 0 > from the code, how will we get the

Re: Perl loop

2007-12-14 Thread John W . Krahn
On Friday 14 December 2007 19:01, jeff pang wrote: > > --- "John W.Krahn" <[EMAIL PROTECTED]> wrote: > > > > No, you would have to do: > > > > if ( !system($touchcmd) && !system($chkstat) ) > > I have thought that, if the unix command's author doesn't return a 0 > from the code, how will we get the

Re: Perl loop

2007-12-14 Thread Chas. Owens
On Dec 14, 2007 10:01 PM, jeff pang <[EMAIL PROTECTED]> wrote: snip > When I complied it and run it: > > $ ./test > hello world > > then get the value of $?: > > $ echo $? > 1 > > It's 1 not 0. > How do you think about this case? :) snip If it is in-house, I would find the culprit and beat him or

Re: Perl loop

2007-12-14 Thread jeff pang
--- "John W.Krahn" <[EMAIL PROTECTED]> wrote: > > No, you would have to do: > > if ( !system($touchcmd) && !system($chkstat) ) > I have thought that, if the unix command's author doesn't return a 0 from the code, how will we get the result of a system command was executed successfully or not?

Re: Perl loop

2007-12-14 Thread John W . Krahn
On Friday 14 December 2007 11:55, Martin Barth wrote: > > tat do? > > sorry john, > what do you mean by that? :( > > I took the code: > > #!/bin/perl > > $interfaces="Output - working interface"; > $chkstat="cat tmp"; > $touchcmd="touch test"; > if (system($touchcmd) && system($chkstat)) { > > from

Re: Perl loop

2007-12-14 Thread Martin Barth
tat do? sorry john, what do you mean by that? :( I took the code: #!/bin/perl $interfaces="Output - working interface"; $chkstat="cat tmp"; $touchcmd="touch test"; if (system($touchcmd) && system($chkstat)) { from the first e-mail -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional

Re: Perl loop

2007-12-14 Thread John W . Krahn
On Friday 14 December 2007 09:29, Martin Barth wrote: > > Hi Hello, > > Perhaps $touchcmd and $chkstat could be done in perl instead of > > running them in an external process? What exactly do $touchcmd and > > $chkstat do? > > $chkstat="cat tmp"; > > The source looks to me that you only want to

Re: Perl loop

2007-12-14 Thread Martin Barth
Hi > Perhaps $touchcmd and $chkstat could be done in perl instead of running > them in an external process? What exactly do $touchcmd and $chkstat do? $chkstat="cat tmp"; The source looks to me that you only want to see if the file is created or not? you can simply call open(); to check this f

Re: Perl loop

2007-12-14 Thread John W . Krahn
On Friday 14 December 2007 05:31, [EMAIL PROTECTED] wrote: > > Hello List, Hello, > I am having two conditions in the perl program. after the check it > will be regenerated to a valid or notvalid file depending on the > check. > > Checking " if (system($touchcmd) && system($chkstat)) " as conditi

Re: Perl loop

2007-12-14 Thread Jay Savage
On Dec 14, 2007 9:00 AM, <[EMAIL PROTECTED]> wrote: > Thanks Jeff. > > How will this be considered. > > if(system(CondA) && system(CondB)) ... > > I am getting 0 as the $? RC...but goes to the else part of the if-statement. > Both the conditions (Unix commands are executed). Is it taking the Cond

Re: Perl loop

2007-12-14 Thread manojkumarg
Digging on thisto make it work. Thanks again. - Original Message - From: jeff pang <[EMAIL PROTECTED]> Date: Friday, December 14, 2007 7:45 pm Subject: Re: Perl loop To: [EMAIL PROTECTED] Cc: "beginners@perl.org" > --- [EMAIL PROTECTED] wrote: > > &g

Re: Perl loop

2007-12-14 Thread jeff pang
--- [EMAIL PROTECTED] wrote: > Thanks Jeff. > > How will this be considered. > > if(system(CondA) && system(CondB)) ... > I'd better write it as: system "cronA && cronB"; if ($? == 0 ) { do something... } Best Regards, Jeff (joy) Peng ___

Re: Perl loop

2007-12-14 Thread manojkumarg
--- From: jeff pang <[EMAIL PROTECTED]> Date: Friday, December 14, 2007 7:09 pm Subject: Re: Perl loop To: [EMAIL PROTECTED], "beginners@perl.org" > --- [EMAIL PROTECTED] wrote: > > > > > Checking " if (system($touchcmd) && system($chkstat)) " a

Re: Perl loop

2007-12-14 Thread jeff pang
--- [EMAIL PROTECTED] wrote: > > Checking " if (system($touchcmd) && system($chkstat)) " as > condition. Is this a valid one? also was trying to get this done > buy calling subroutine. > No. Generally when an unix command was executed successfully, it will return 0. ie, $ perl -le '$s = sys