Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How can i execute "cal" of UNIX in xxx.pl ?

Reply
Thread Tools

How can i execute "cal" of UNIX in xxx.pl ?

 
 
silvester
Guest
Posts: n/a
 
      11-03-2003
Here is my code. ↓ (of course i have another relative xxx.html)

#!/usr/local/bin/perl
do "cgi-lib.pl"||die "error\n";
&ReadParse;
exec "cal $in{month} $in{year}";
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
↑Here is my question.
i can't exec cal with month & year at the same time.
for example,
i can't exec "cal 11 2003";
but it's ok to exec "cal 2003";

what's wrong?
or that's not supported by Perl?

i need help, please.
 
Reply With Quote
 
 
 
 
Darin McBride
Guest
Posts: n/a
 
      11-03-2003
silvester wrote:

> Here is my code. ↓ (of course i have another relative xxx.html)
>
> #!/usr/local/bin/perl
> do "cgi-lib.pl"||die "error\n";
> &ReadParse;
> exec "cal $in{month} $in{year}";
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> ↑Here is my question.
> i can't exec cal with month & year at the same time.
> for example,
> i can't exec "cal 11 2003";
> but it's ok to exec "cal 2003";
>
> what's wrong?
> or that's not supported by Perl?
>
> i need help, please.


$ perl -e '$in{m}=11;$in{y}=2003;exec "cal $in{m} $in{y}";'
November 2003
Su Mo Tu We Th Fr Sa
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30

Works fine for me ... you may want to upgrade to a newer style of perl,
e.g., one that doesn't use cgi-lib.pl

Also, run your script through a debugger:

$ perl -d xxx.pl

Check what %in contains after ReadParse.

Finally, if this is a CGI script, cal may or may not be in your PATH at that
point. Try running with a full pathname, e.g. exec "/usr/bin/cal ..." (if
that's where cal is on your system).
 
Reply With Quote
 
 
 
 
Ben Morrow
Guest
Posts: n/a
 
      11-03-2003

http://www.velocityreviews.com/forums/(E-Mail Removed) (silvester) wrote:
> Here is my code. ↓ (of course i have another relative

^^^^^^^
What is this?

> xxx.html)




>
> #!/usr/local/bin/perl
> do "cgi-lib.pl"||die "error\n";
> &ReadParse;


AAARGH! nononononono this is Perl4.

Read
perldoc -f use
perldoc perlmod
perldoc CGI

> exec "cal $in{month} $in{year}";
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> ↑Here is my question.
> i can't exec cal with month & year at the same time.
> for example,
> i can't exec "cal 11 2003";
> but it's ok to exec "cal 2003";


What do you mean by 'i can't' and 'but it's ok'? What happens? What
error messages do you get, or what output do you get that you didn't
want?

Also, you haven't printed an HTTP header yet.

Ben

--
For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * (E-Mail Removed)
 
Reply With Quote
 
James Willmore
Guest
Posts: n/a
 
      11-03-2003
On 3 Nov 2003 09:39:46 -0800
(E-Mail Removed) (silvester) wrote:
> Here is my code. ↓ (of course i have another relative
> xxx.html)
>
> #!/usr/local/bin/perl


Put a '-w' at the end of that first line to enable warnings.

> do "cgi-lib.pl"||die "error\n";


This is a Perl 4 (meaning, the _latest_ version of Perl is 5.8.1)
library. Use the CGI module instead.

> &ReadParse;


Ditto

> exec "cal $in{month} $in{year}";


You _want_ the results of 'cat', don't you? Then use 'system', not
'exec'.

And .... Perl has _several_ modules to perform the same functions (and
then some) as 'cal'.

HTH

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
Playing an unamplified electric guitar is like strumming on a
<picnic table. -- Dave Barry, "The Snake"
 
Reply With Quote
 
Alan J. Flavell
Guest
Posts: n/a
 
      11-03-2003
On Mon, 3 Nov 2003, Ben Morrow wrote:

> (E-Mail Removed) (silvester) wrote:
> > Here is my code. ↓ (of course i have another relative

> ^^^^^^^
> What is this?


An un-called-for HTML-ised character reference to a downwards arrow,
I'd say.

Since the original posting's header said:

Content-Type: text/plain; charset=ISO-8859-1

it had no business using unsolicited "numerical character references".
Guess whose software I'd tend to blame? (By the time the posting's
gone through the Googroups gateway that the hon Usenaut was using in
place of a real nntp server, there may little sign of the identity of
the original "client" software that was used to access Googloups, but
I have my suspicions...)

> AAARGH! nononononono this is Perl4.


"run away!" )

 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      11-04-2003
James Willmore <(E-Mail Removed)> wrote:
> On 3 Nov 2003 09:39:46 -0800
> (E-Mail Removed) (silvester) wrote:



>> do "cgi-lib.pl"||die "error\n";

>
> This is a Perl 4 (meaning, the _latest_ version of Perl is 5.8.1)



Also meaning:

It is 9 year old code.

It is contemporary with Windows 3.1 (are you still using that too?).


But the most pragmatic reason for switching to CGI.pm is:

Nobody will help you when you have problems.

It is hard to get worked up about stuff that old...


>> exec "cal $in{month} $in{year}";

>
> You _want_ the results of 'cat', don't you? Then use 'system', not
> 'exec'.



Huh?

That is either the wrong question or the wrong answer...

You _want_ the results of 'cat', don't you? Then use backticks, not exec.

You _want_ to have some more Perl program after launching "cal",
don't you? Then use 'system', not 'exec'.


--
Tad McClellan SGML consulting
(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to execute script in unix (remote server) via asp application? nimhyea@gmail.com ASP General 2 02-18-2008 06:35 PM
compile C programs with UNIX system calls (= Unix Programs??) jrefactors@hotmail.com C++ 12 01-10-2005 03:35 AM
Can i execute aspx file in my asp pag with server.execute method(sorry) Savas Ates ASP General 1 08-17-2004 04:52 PM
execute a unix command Alex Perl Misc 3 01-07-2004 04:05 PM



Advertisments