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

S

silvester

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.
 
D

Darin McBride

silvester said:
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).
 
B

Ben Morrow

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
 
J

James Willmore

On 3 Nov 2003 09:39:46 -0800
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"
 
A

Alan J. Flavell

^^^^^^^
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!" ;-))
 
T

Tad McClellan

James Willmore said:
On 3 Nov 2003 09:39:46 -0800
(e-mail address removed) (silvester) wrote:


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...

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'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top