1827459 Members
4002 Online
109965 Solutions
New Discussion

Re: Perl Execute Help

 
SOLVED
Go to solution
Steven Chen_1
Super Advisor

Perl Execute Help

Hi,

I need help: I try to get UNIX shell scripts working in Windows environment by using perl, somehow I fail.

1) on cmd prompt:
perl -i.save -p -e "s/DEVELOP/PRODUCTION/gi" c:\temp\test1.txt

it is working as desired.

2) if I make a mytest.pl file as

c:\perl\bin\perl.exe -i.save -p -s "s/DEVELOP/PRODUCTION/gi" c:\temp\test1.txt

then execute from cmd prompt as c:\perl\bin\perl mytest.pl, I get error like "panic: uf16_to_uft8: odd bytlen 155"

3) if I make a batch file test.bat as

c:\perl\bin\perl.exe -i.save -p -e "s/DEVELOP/PRODUCTION/gi" c:\temp\test1.txt

from cmd prompt issue test.bat, or use AT command for scheduling, batch is executed, but nothing happened to the file.

4) I have 10+ batches consisting of a whole job. In UNIX, shell script makes it easy by just listing each command as "sh a1" as 1st, "sh a2" as 2nd, and so on in a file. The job will be executed in order.

In windows, I would like to see how people get around to do the job. Please help as you can.

Appreciated.

Steven
Steve
6 REPLIES 6
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Perl Execute Help

I have no problem at all running perl in .bat files, in fact, I just run this exact file as test.bat and it behaved exactly as expected:

perl -i.save -p -e "s/DEVELOP/PRODUCTION/gi" xx.txt

I suspect what is wrong is that your @INC is not setup correctly.

Execute perl -V and look for @INC very near the end of your output.

You can set @INC by add -I arguments to your perl execution line and this is required if you are running for example, a pre-exec for Data Protector

Your command would look something like this:

perl -I C:/Perl/lib -I C:/Perl/site/lib myscript.pl

assuming that C:\Perl\bin is also somewhere in your PATH --- and no, I did not get the slashes backwards for the -I argument --- and why aren't you asking a Windows question elsewhere??
If it ain't broke, I can fix that.
Peter Nikitka
Honored Contributor

Re: Perl Execute Help

Hi,

1) OK
2) You have to put perl code into the .pl file, not the command itself:
c:\ type mytest.pl
s/DEVELOP/PRODUCTION/gi
c:\ \perl\bin\perl.exe -i.save -p \temp\mytest.pl \temp\test1.txt

3) The .bat should work, if all required parameters and options are founnd in it.
consider a
C:
or equiv. to get a well defined '\'

At jobs need a 'cmd /c' wrapped around a .bat mostly.

4) Write your script completly in perl.

mfG Peter
... who normally tries to avoid to deal with such PC stuff.
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
H.Merijn Brand (procura
Honored Contributor

Re: Perl Execute Help

In windows environments I install Cygwin. That's probably the only sane way to work with windows anyway.

Feel free to give no points if this is totally useless info for you.

Windows is hateful. In all respects.

You might try binmode or -C3 option

binmode STDIN, ":utf8";
binmode STDOUT, ":utf8";

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Steven Chen_1
Super Advisor

Re: Perl Execute Help

A. Clay,

You are exactly right. "perl -V" returns with:

Perl lib version doesn't match executable version (v5.8.8> at d:\oracle\product\.....\perl\5.8.3\lib.MSWin32-x86-...../config.pm line 32. compilation failed in require.

I have Oracle 10g installed before installing perl 5.8.8.

Do you think uninstalling perl 5.8.8 then installing 5.8.3 will work? Or just use Oracle perl binary?

Thanks.
Steve
A. Clay Stephenson
Acclaimed Contributor

Re: Perl Execute Help

You are now asking official stupid Windows questions. Have you looked at the Forum under which you are posting? I have already soiled my hands enough but on UNIX boxes multiple versions of Perl have no trouble co-existing -- if you know what you are doing. Find yourself a Windows forum or a Perl forum but whatever you are asking it ain't HP-UX!!!
If it ain't broke, I can fix that.
Steven Chen_1
Super Advisor

Re: Perl Execute Help

A. Clay,

Sorry to bother you, I wasn't pay realized that it is hpux forum.

Thanks for any help.
Steve