📄 perlos2.1
字号:
.PP.Vb 1\& extproc perl \-S \-my_opts.Ve.PPrename your program to \fIfoo.cmd\fR, and start it by typing.PP.Vb 1\& foo arg1 arg2 arg3.Ve.PPNote that because of stupid \s-1OS/2\s0 limitations the full path of the perlscript is not available when you use \f(CW\*(C`extproc\*(C'\fR, thus you are forced touse \f(CW\*(C`\-S\*(C'\fR perl switch, and your script should be on the \f(CW\*(C`PATH\*(C'\fR. As a plusside, if you know a full path to your script, you may still start itwith.PP.Vb 1\& perl ../../blah/foo.cmd arg1 arg2 arg3.Ve.PP(note that the argument \f(CW\*(C`\-my_opts\*(C'\fR is taken care of by the \f(CW\*(C`extproc\*(C'\fR linein your script, see "\f(CW\*(C`extproc\*(C'\fR on the first line")..PPTo understand what the above \fImagic\fR does, read perl docs about \f(CW\*(C`\-S\*(C'\fRswitch \- see perlrun, and cmdref about \f(CW\*(C`extproc\*(C'\fR:.PP.Vb 4\& view perl perlrun\& man perlrun\& view cmdref extproc\& help extproc.Ve.PPor whatever method you prefer..PPThere are also endless possibilities to use \fIexecutable extensions\fR of4os2, \fIassociations\fR of \s-1WPS\s0 and so on... However, if you use*nixish shell (like \fIsh.exe\fR supplied in the binary distribution),you need to follow the syntax specified in \*(L"Switches\*(R" in perlrun..PPNote that \fB\-S\fR switch supports scripts with additional extensions \&\fI.cmd\fR, \fI.btm\fR, \fI.bat\fR, \fI.pl\fR as well..Sh "Starting \s-1OS/2\s0 (and \s-1DOS\s0) programs under Perl".IX Subsection "Starting OS/2 (and DOS) programs under Perl"This is what \fIsystem()\fR (see \*(L"system\*(R" in perlfunc), \f(CW\*(C`\`\`\*(C'\fR (see\&\*(L"I/O Operators\*(R" in perlop), and \fIopen pipe\fR (see \*(L"open\*(R" in perlfunc)are for. (Avoid \fIexec()\fR (see \*(L"exec\*(R" in perlfunc) unless you know what youdo)..PPNote however that to use some of these operators you need to have ash-syntax shell installed (see \*(L"Pdksh\*(R", \&\*(L"Frequently asked questions\*(R"), and perl should be able to find it(see \*(L"\s-1PERL_SH_DIR\s0\*(R")..PPThe cases when the shell is used are:.IP "1." 4One-argument \fIsystem()\fR (see \*(L"system\*(R" in perlfunc), \fIexec()\fR (see \*(L"exec\*(R" in perlfunc)with redirection or shell meta-characters;.IP "2." 4Pipe-open (see \*(L"open\*(R" in perlfunc) with the command which contains redirection or shell meta-characters;.IP "3." 4Backticks \f(CW\*(C`\`\`\*(C'\fR (see \*(L"I/O Operators\*(R" in perlop) with the command which containsredirection or shell meta-characters;.IP "4." 4If the executable called by \fIsystem()\fR/\fIexec()\fR/pipe\-\fIopen()\fR/\f(CW\*(C`\`\`\*(C'\fR is a scriptwith the \*(L"magic\*(R" \f(CW\*(C`#!\*(C'\fR line or \f(CW\*(C`extproc\*(C'\fR line which specifies shell;.IP "5." 4If the executable called by \fIsystem()\fR/\fIexec()\fR/pipe\-\fIopen()\fR/\f(CW\*(C`\`\`\*(C'\fR is a scriptwithout \*(L"magic\*(R" line, and \f(CW$ENV{EXECSHELL}\fR is set to shell;.IP "6." 4If the executable called by \fIsystem()\fR/\fIexec()\fR/pipe\-\fIopen()\fR/\f(CW\*(C`\`\`\*(C'\fR is notfound (is not this remark obsolete?);.IP "7." 4For globbing (see \*(L"glob\*(R" in perlfunc, \*(L"I/O Operators\*(R" in perlop)(obsolete? Perl uses builtin globbing nowadays...)..PPFor the sake of speed for a common case, in the above algorithms backslashes in the command name are not considered as shell metacharacters..PPPerl starts scripts which begin with cookies\&\f(CW\*(C`extproc\*(C'\fR or \f(CW\*(C`#!\*(C'\fR directly, without an intervention of shell. Perl uses thesame algorithm to find the executable as \fIpdksh\fR: if the pathon \f(CW\*(C`#!\*(C'\fR line does not work, and contains \f(CW\*(C`/\*(C'\fR, then the directorypart of the executable is ignored, and the executableis searched in \fI.\fR and on \f(CW\*(C`PATH\*(C'\fR. To find arguments for these scriptsPerl uses a different algorithm than \fIpdksh\fR: up to 3 arguments are recognized, and trailing whitespace is stripped..PPIf a scriptdoes not contain such a cooky, then to avoid calling \fIsh.exe\fR, Perl usesthe same algorithm as \fIpdksh\fR: if \f(CW$ENV{EXECSHELL}\fR is set, thescript is given as the first argument to this command, if not set, then\&\f(CW\*(C`$ENV{COMSPEC} /c\*(C'\fR is used (or a hardwired guess if \f(CW$ENV{COMSPEC}\fR isnot set)..PPWhen starting scripts directly, Perl uses exactly the same algorithm as for the search of script given by \fB\-S\fR command-line option: it will look inthe current directory, then on components of \f(CW$ENV{PATH}\fR using the following order of appended extensions: no extension, \fI.cmd\fR, \fI.btm\fR, \&\fI.bat\fR, \fI.pl\fR..PPNote that Perl will start to look for scripts only if \s-1OS/2\s0 cannot start thespecified application, thus \f(CW\*(C`system \*(Aqblah\*(Aq\*(C'\fR will not look for a script if there is an executable file \fIblah.exe\fR \fIanywhere\fR on \f(CW\*(C`PATH\*(C'\fR. Inother words, \f(CW\*(C`PATH\*(C'\fR is essentially searched twice: once by the \s-1OS\s0 foran executable, then by Perl for scripts..PPNote also that executable files on \s-1OS/2\s0 can have an arbitrary extension, but \fI.exe\fR will be automatically appended if no dot is present in the name. The workaround is as simple as that: since \fIblah.\fR and \fIblah\fR denote the same file (at list on \s-1FAT\s0 and \s-1HPFS\s0 file systems), to start an executable residing in file \fIn:/bin/blah\fR (no extension) give an argument \f(CW\*(C`n:/bin/blah.\*(C'\fR (dot appended) to \fIsystem()\fR..PPPerl will start \s-1PM\s0 programs from \s-1VIO\s0 (=text\-mode) Perl process in aseparate \s-1PM\s0 session;the opposite is not true: when you start a non-PM program from a \s-1PM\s0Perl process, Perl would not run it in a separate session. If a separatesession is desired, either ensurethat shell will be used, as in \f(CW\*(C`system \*(Aqcmd /c myprog\*(Aq\*(C'\fR, or start it usingoptional arguments to \fIsystem()\fR documented in \f(CW\*(C`OS2::Process\*(C'\fR module. Thisis considered to be a feature..SH "Frequently asked questions".IX Header "Frequently asked questions".ie n .Sh """It does not work""".el .Sh "``It does not work''".IX Subsection "It does not work"Perl binary distributions come with a \fItestperl.cmd\fR script which triesto detect common problems with misconfigured installations. There is apretty large chance it will discover which step of the installation youmanaged to goof. \f(CW\*(C`;\-)\*(C'\fR.Sh "I cannot run external programs".IX Subsection "I cannot run external programs".IP "\(bu" 4Did you run your programs with \f(CW\*(C`\-w\*(C'\fR switch? See \&\*(L"2 (and \s-1DOS\s0) programs under Perl\*(R" in Starting \s-1OS\s0..IP "\(bu" 4Do you try to run \fIinternal\fR shell commands, like \f(CW\*(C`\`copy a b\`\*(C'\fR(internal for \fIcmd.exe\fR), or \f(CW\*(C`\`glob a*b\`\*(C'\fR (internal for ksh)? Youneed to specify your shell explicitly, like \f(CW\*(C`\`cmd /c copy a b\`\*(C'\fR,since Perl cannot deduce which commands are internal to your shell..Sh "I cannot embed perl into my program, or use \fIperl.dll\fP from my program.".IX Subsection "I cannot embed perl into my program, or use perl.dll from my program.".ie n .IP "Is your program EMX-compiled with ""\-Zmt \-Zcrtdll""?" 4.el .IP "Is your program EMX-compiled with \f(CW\-Zmt \-Zcrtdll\fR?" 4.IX Item "Is your program EMX-compiled with -Zmt -Zcrtdll?"Well, nowadays Perl \s-1DLL\s0 should be usable from a differently compiledprogram too... If you can run Perl code from \s-1REXX\s0 scripts (see\&\s-1OS2::REXX\s0), then there are some other aspect of interaction whichare overlooked by the current hackish code to supportdifferently-compiled principal programs..SpIf everything else fails, you need to build a stand-alone \s-1DLL\s0 forperl. Contact me, I did it once. Sockets would not work, as a lot ofother stuff..IP "Did you use ExtUtils::Embed?" 4.IX Item "Did you use ExtUtils::Embed?"Some time ago I had reports it does not work. Nowadays it is checkedin the Perl test suite, so grep \fI./t\fR subdirectory of the build tree(as well as \fI*.t\fR files in the \fI./lib\fR subdirectory) to find how itshould be done \*(L"correctly\*(R"..ie n .Sh """\`\`""\fP and pipe\-\f(CW""open"" do not work under \s-1DOS\s0.".el .Sh "\f(CW\`\`\fP and pipe\-\f(CWopen\fP do not work under \s-1DOS\s0.".IX Subsection " and pipe-open do not work under DOS."This may a variant of just \*(L"I cannot run external programs\*(R", or adeeper problem. Basically: you \fIneed\fR \s-1RSX\s0 (see \*(L"Prerequisites\*(R")for these commands to work, and you may need a port of \fIsh.exe\fR whichunderstands command arguments. One of such ports is listed in\&\*(L"Prerequisites\*(R" under \s-1RSX\s0. Do not forget to set variable\&\f(CW"PERL_SH_DIR"\fR as well..PP\&\s-1DPMI\s0 is required for \s-1RSX\s0..ie n .Sh "Cannot start ""find.exe ""pattern"" file""".el .Sh "Cannot start \f(CWfind.exe ``pattern'' file\fP".IX Subsection "Cannot start find.exe ""pattern"" file"The whole idea of the \*(L"standard C \s-1API\s0 to start applications\*(R" is thatthe forms \f(CW\*(C`foo\*(C'\fR and \f(CW"foo"\fR of program arguments are completelyinterchangable. \fIfind\fR breaks this paradigm;.PP.Vb 2\& find "pattern" file\& find pattern file.Ve.PPare not equivalent; \fIfind\fR cannot be started directly using the above\&\s-1API\s0. One needs a way to surround the doublequotes in some otherquoting construction, necessarily having an extra non-Unixish shell inbetween..PPUse one of.PP.Vb 2\& system \*(Aqcmd\*(Aq, \*(Aq/c\*(Aq, \*(Aqfind "pattern" file\*(Aq;\& \`cmd /c \*(Aqfind "pattern" file\*(Aq\`.Ve.PPThis would start \fIfind.exe\fR via \fIcmd.exe\fR via \f(CW\*(C`sh.exe\*(C'\fR via\&\f(CW\*(C`perl.exe\*(C'\fR, but this is a price to pay if you want to usenon-conforming program..SH "INSTALLATION".IX Header "INSTALLATION".Sh "Automatic binary installation".IX Subsection "Automatic binary installation"The most convenient way of installing a binary distribution of perl is via perl installer\&\fIinstall.exe\fR. Just follow the instructions, and 99% of theinstallation blues would go away..PPNote however, that you need to have \fIunzip.exe\fR on your path, and\&\s-1EMX\s0 environment \fIrunning\fR. The latter means that if you justinstalled \s-1EMX\s0, and made all the needed changes to \fIConfig.sys\fR,you may need to reboot in between. Check \s-1EMX\s0 runtime by running.PP.Vb 1\& emxrev.Ve.PPBinary installer also creates a folder on your desktop with some usefulobjects. If you need to change some aspects of the work of the binaryinstaller, feel free to edit the file \fIPerl.pkg\fR. This may be usefule.g., if you need to run the installer many times and do not want tomake many interactive changes in the \s-1GUI\s0..PP\&\fBThings not taken care of by automatic binary installation:\fR.ie n .IP """PERL_BADLANG""" 15.el .IP "\f(CWPERL_BADLANG\fR" 15.IX Item "PERL_BADLANG"may be needed if you change your codepage \fIafter\fR perl installation,and the new value is not supported by \s-1EMX\s0. See \*(L"\s-1PERL_BADLANG\s0\*(R"..ie n .IP """PERL_BADFREE""" 15.el .IP "\f(CWPERL_BADFREE\fR" 15.IX Item "PERL_BADFREE"see \*(L"\s-1PERL_BADFREE\s0\*(R"..IP "\fIConfig.pm\fR" 15.IX Item "Config.pm"This file resides somewhere deep in the location you installed yourperl library, find it out by.Sp.Vb 1\& perl \-MConfig \-le "print $INC{\*(AqConfig.pm\*(Aq}".Ve.SpWhile most important values in this file \fIare\fR updated by the binaryinstaller, some of them may need to be hand-edited. I know no suchdata, please keep me informed if you find one. Moreover, manualchanges to the installed version may need to be accompanied by an editof this file..PP\&\fB\s-1NOTE\s0\fR. Because of a typo the binary installer of 5.00305would install a variable \f(CW\*(C`PERL_SHPATH\*(C'\fR into \fIConfig.sys\fR. Pleaseremove this variable and put \f(CW\*(C`PERL_SH_DIR\*(C'\fR instead..Sh "Manual binary installation".IX Subsection "Manual binary installation"As of version 5.00305, \s-1OS/2\s0 perl binary distribution comes splitinto 11 components. Unfortunately, to enable configurable binaryinstallation, the file paths in the zip files are not absolute, butrelative to some directory..PPNote that the extraction with the stored paths is still necessary(default with unzip, specify \f(CW\*(C`\-d\*(C'\fR to pkunzip). However, youneed to know where to extract the files. You need also to manuallychange entries in \fIConfig.sys\fR to reflect where did you put thefiles. Note that if you have some primitive unzipper (like\&\f(CW\*(C`pkunzip\*(C'\fR), you may get a lot of warnings/errors duringunzipping. Upgrade to \f(CW\*(C`(w)unzip\*(C'\fR..PPBelow is the sample of what to do to reproduce the configuration on mymachine. In \fI\s-1VIEW\s0.EXE\fR you can press \f(CW\*(C`Ctrl\-Insert\*(C'\fR now, andcut-and-paste from the resulting file \- created in the directory youstarted \fI\s-1VIEW\s0.EXE\fR from..PPFor each component, we mention environment variables related to eachinstallation directory. Either choose directories to match yourvalues of the variables, or create/append\-to variables to take intoaccount the directories..IP "Perl \s-1VIO\s0 and \s-1PM\s0 executables (dynamically linked)" 3.IX Item "Perl VIO and PM executables (dynamically linked)".Vb 2\& unzip perl_exc.zip *.exe *.ico \-d f:/emx.add/bin\& unzip perl_exc.zip *.dll \-d f:/emx.add/dll.Ve.Sp(have the directories with \f(CW\*(C`*.exe\*(C'\fR on \s-1PATH\s0, and \f(CW\*(C`*.dll\*(C'\fR on\&\s-1LIBPATH\s0);.IP "Perl_ \s-1VIO\s0 executable (statically linked)" 3.IX Item "Perl_ VIO executable (statically linked)".Vb 1\& unzip perl_aou.zip \-d f:/emx.add/bin.Ve.Sp(have the directory on \s-1PATH\s0);.IP "Executables for Perl utilities" 3.IX Item "Executables for Perl utilities".Vb 1\& unzip perl_utl.zip \-d f:/emx.add/bin.Ve.Sp(have the directory on \s-1PATH\s0);.IP "Main Perl library" 3.IX Item "Main Perl library".Vb 1\& unzip perl_mlb.zip \-d f:/perllib/lib.Ve.SpIf this directory is exactly the same as the prefix which was compiledinto \fIperl.exe\fR, you do not need to changeanything. However, for perl to find the library if you use a differentpath, you need to\&\f(CW\*(C`set PERLLIB_PREFIX\*(C'\fR in \fIConfig.sys\fR, see \*(L"\s-1PERLLIB_PREFIX\s0\*(R"..IP "Additional Perl modules" 3.IX Item "Additional Perl modules".Vb 1\& unzip perl_ste.zip \-d f:/perllib/lib/site_perl/5.8.3/.Ve.SpSame remark as above applies. Additionally, if this directory is notone of directories on \f(CW@INC\fR (and \f(CW@INC\fR is influenced by \f(CW\*(C`PERLLIB_PREFIX\*(C'\fR), youneed to put thisdirectory and subdirectory \fI./os2\fR in \f(CW\*(C`PERLLIB\*(C'\fR or \f(CW\*(C`PERL5LIB\*(C'\fRvariable. Do not use \f(CW\*(C`PERL5LIB\*(C'\fR unless you have it set already. See\&\*(L"\s-1ENVIRONMENT\s0\*(R" in perl..Sp\&\fB[Check whether this extraction directory is still applicable withthe new directory structure layout!]\fR.IP "Tools to compile Perl modules" 3.IX Item "Tools to compile Perl modules".Vb 1\& unzip perl_blb.zip \-d f:/perllib/lib
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -