バッチファイルプログ ..
775:デフォルトの名無しさん
07/03/23 19:41:08
=head2 DISADVANTAGES
There are several potential traps you should be aware of when you
use B<pl2bat>.
The generated batch file is initially processed as a batch file each
time it is run. This means that, to use it from within another batch
file you should preceed it with C<call> or else the calling batch
file will not run any commands after the script:
call script [args]
Except under Windows NT, if you specify more than 9 arguments to
the generated batch file then the 10th and subsequent arguments
are silently ignored.
Except when using F<CMD.EXE> under Windows NT, if F<perl.exe> is not
in your B<PATH>, then trying to run the script will give you a generic
"Command not found"-type of error message that will probably make you
think that the script itself is not in your B<PATH>. When using
F<CMD.EXE> under Windows NT, the generic error message is followed by
"You do not have Perl in your PATH", to make this clearer.
On most DOS-like operating systems, the only way to exit a batch file
is to "fall off the end" of the file. B<pl2bat> implements this by
doing C<goto :endofperl> and adding C<__END__> and C<:endofperl> as
the last two lines of the generated batch file. This means:
776:デフォルトの名無しさん
07/03/23 19:41:56
=over
=item No line of your script should start with a colon.
In particular, for this version of B<pl2bat>, C<:endofperl>,
C<:WinNT>, and C<:script_failed_so_exit_with_non_zero_val> should not
be used.
=item Care must be taken when using C<__END__> and the C<DATA> file handle.
One approach is:
. #!perl
. while( <DATA> ) {
. last if /^__END__$/;
. [...]
. }
. __END__
. lines of data
. to be processed
. __END__
. :endofperl
The dots in the first column are only there to prevent F<cmd.exe> to interpret
the C<:endofperl> line in this documentation. Otherwise F<pl2bat.bat> itself
wouldn't work. See the previous item. :-)
777:デフォルトの名無しさん
07/03/23 19:42:48
=item The batch file always "succeeds"
The following commands illustrate the problem:
C:> echo exit(99); >fail.pl
C:> pl2bat fail.pl
C:> perl -e "print system('perl fail.pl')"
99
C:> perl -e "print system('fail.bat')"
0
So F<fail.bat> always reports that it completed successfully. Actually,
under Windows NT, we have:
C:> perl -e "print system('fail.bat')"
1
So, for Windows NT, F<fail.bat> fails when the Perl script fails, but
the return code is always C<1>, not the return code from the Perl script.
778:デフォルトの名無しさん
07/03/23 19:46:18
=head1 NAME
pl2bat - wrap perl code into a batch file
=head1 SYNOPSIS
B<pl2bat> B<-h>
B<pl2bat> [B<-w>] S<[B<-a> I<argstring>]> S<[B<-s> I<stripsuffix>]> [files]
B<pl2bat> [B<-w>] S<[B<-n> I<ntargs>]> S<[B<-o> I<otherargs>]> S<[B<-s> I<stripsuffix>]> [files]
=head1 DESCRIPTION
This utility converts a perl script into a batch file that can be
executed on DOS-like operating systems. This is intended to allow
you to use a Perl script like regular programs and batch files where
you just enter the name of the script [probably minus the extension]
plus any command-line arguments and the script is found in your B<PATH>
and run.
779:デフォルトの名無しさん
07/03/23 19:47:15
=back
=head2 FUNCTION
By default, the ".pl" suffix will be stripped before adding a ".bat" suffix
to the supplied file names. This can be controlled with the C<-s> option.
The default behavior is to have the batch file compare the C<OS>
environment variable against C<"Windows_NT">. If they match, it
uses the C<%*> construct to refer to all the command line arguments
that were given to it, so you'll need to make sure that works on your
variant of the command shell. It is known to work in the F<CMD.EXE> shell
under Windows NT. 4DOS/NT users will want to put a C<ParameterChar = *>
line in their initialization file, or execute C<setdos /p*> in
the shell startup file.
On Windows95 and other platforms a nine-argument limit is imposed
on command-line arguments given to the generated batch file, since
they may not support C<%*> in batch files.
These can be overridden using the C<-n> and C<-o> options or the
deprecated C<-a> option.
780:デフォルトの名無しさん
07/03/23 19:47:54
=head1 OPTIONS
=over 8
=item B<-n> I<ntargs>
Arguments to invoke perl with in generated batch file when run from
Windows NT (or Windows 98, probably). Defaults to S<'-x -S %0 %*'>.
=item B<-o> I<otherargs>
Arguments to invoke perl with in generated batch file except when
run from Windows NT (ie. when run from DOS, Windows 3.1, or Windows 95).
Defaults to S<'-x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9'>.
=item B<-a> I<argstring>
Arguments to invoke perl with in generated batch file. Specifying
B<-a> prevents the batch file from checking the C<OS> environment
variable to determine which operating system it is being run from.
=item B<-s> I<stripsuffix>
Strip a suffix string from file name before appending a ".bat"
suffix. The suffix is not case-sensitive. It can be a regex if
it begins with `/' (the trailing '/' is optional and a trailing
C<$> is always assumed). Defaults to C</.plx?/>.
781:デフォルトの名無しさん
07/03/23 19:48:41
=item B<-w>
If no line matching C</^#!.*perl/> is found in the script, then such
a line is inserted just after the new preamble. The exact line
depends on C<$Config{startperl}> [see L<Config>]. With the B<-w>
option, C<" -w"> is added after the value of C<$Config{startperl}>.
If a line matching C</^#!.*perl/> already exists in the script,
then it is not changed and the B<-w> option is ignored.
=item B<-u>
If the script appears to have already been processed by B<pl2bat>,
then the script is skipped and not processed unless B<-u> was
specified. If B<-u> is specified, the existing preamble is replaced.
=item B<-h>
Show command line usage.
=back
782:デフォルトの名無しさん
07/03/23 19:54:41
=head1 EXAMPLES
C:\> pl2bat foo.pl bar.PM
[..creates foo.bat, bar.PM.bat..]
C:\> pl2bat -s "/\.pl|\.pm/" foo.pl bar.PM
[..creates foo.bat, bar.bat..]
C:\> pl2bat < somefile > another.bat
C:\> pl2bat > another.bat
print scalar reverse "rekcah lrep rehtona tsuj\n";
^Z
[..another.bat is now a certified japh application..]
C:\> ren *.bat *.pl
C:\> pl2bat -u *.pl
[..updates the wrapping of some previously wrapped scripts..]
C:\> pl2bat -u -s .bat *.bat
[..same as previous example except more dangerous..]
783:デフォルトの名無しさん
07/03/23 19:55:16
=head1 BUGS
C<$0> will contain the full name, including the ".bat" suffix
when the generated batch file runs. If you don't like this,
see runperl.bat for an alternative way to invoke perl scripts.
Default behavior is to invoke Perl with the B<-S> flag, so Perl will
search the B<PATH> to find the script. This may have undesirable
effects.
On really old versions of Win32 Perl, you can't run the script
via
C:> script.bat [args]
and must use
C:> script [args]
784:デフォルトの名無しさん
07/03/23 20:00:38
>>758
スレ違いではありません。問題ありません。
785:デフォルトの名無しさん
07/03/23 20:01:02
A loop should be used to build up the argument list when not on
Windows NT so more than 9 arguments can be processed.
See also L</Disadvantages>.
=head1 SEE ALSO
perl, perlwin32, runperl.bat
=cut
__END__
:endofperl
786:デフォルトの名無しさん
07/03/23 20:05:48
This is due to a Win32 bug which Perl has no control over. This bug
is the major motivation for B<pl2bat> [which was originally written
for DOS] being used on Win32 systems.
Note also that B<5> works on a smaller range of combinations of Win32
systems and command shells while B<4> requires that the user know
that the script is a Perl script [because the ".pl" extension must
be entered]. This makes it hard to standardize on either of these
methods.
787:デフォルトの名無しさん
07/03/23 21:26:07
見た目バッチでも中味が他のスクリプト言語を呼んでるだけのはスレ違い
788:787
07/03/23 21:30:14
スレ違いと言うのが快感なんです
789:デフォルトの名無しさん
07/03/23 21:35:06
長いのはアップローダあたりにうpしてほしいです。
790:デフォルトの名無しさん
07/03/23 21:47:36
過疎スレで堅い事言うな
791:デフォルトの名無しさん
07/03/23 21:51:48
来るもの拒まずの精神
792:デフォルトの名無しさん
07/03/23 21:55:02
「スレ違い」という言葉を嘘と見抜けないようではこのスレでやっていけない。
793:デフォルトの名無しさん
07/03/23 21:56:12
大目に見よう
794:デフォルトの名無しさん
07/03/23 22:41:02
これは流石にな…
バッチスレの範疇ってお前らどこまでだと思う?
795:デフォルトの名無しさん
07/03/23 22:43:19
バッチスレの範疇がどこまでかは知らないけど
このスレの範疇は「ファイル拡張子が ".bat"」なのでよろしく。
796:デフォルトの名無しさん
07/03/23 22:48:34
バッチファイルプログラミング 3.bat
となってるけどプログラミングが何かわかってない馬鹿が立てたんだな
797:デフォルトの名無しさん
07/03/23 22:57:12
796は馬鹿
798:デフォルトの名無しさん
07/03/24 04:23:48
>>1-1000
スレ違い
799:デフォルトの名無しさん
07/03/24 07:47:55
つか嵐だろただの。基地外基準にして範疇を語るなと。
800:デフォルトの名無しさん
07/03/24 07:54:53
\(^o^)/800
801:デフォルトの名無しさん
07/03/26 00:13:59
質問させてください。
バッチは、10桁の数値だと正しく計算出来ないんでしょうか。
以下を実行すると、Cが1073741823になります。
set a=9000000000
set b=2
set /a c=a/b
@echo %c%
環境はwinxpです。10桁の計算になると何か制限等があるのでしょうか。
802:デフォルトの名無しさん
07/03/26 00:23:08
2147483647より大きい数は2147483647と見なす仕様
803:デフォルトの名無しさん
07/03/26 00:25:10
>>802
即レスサンクスです
知らなかったよ〜空がこんなにあおーいなんて
804:デフォルトの名無しさん
07/03/26 12:45:43
>>1-1000
すれちがい…
805:デフォルトの名無しさん
07/03/26 16:15:26
>>803
ちなみに16進数に変換すると歯切れの良い数-1になります。
806:デフォルトの名無しさん
07/03/26 16:20:09
スレタイが良くない。
バッチリファイルプログラミングにするべき。
807:デフォルトの名無しさん
07/03/26 16:36:39
プログラム板とは思えない低レベルな展開
808:デフォルトの名無しさん
07/03/27 13:55:49
バッチ処理なんてダサイからな。
今時はリアルタイム処理で即時反映だし。
夜間バッチが動かないと金額がわからないなんて変化についていけないよ。
809:デフォルトの名無しさん
07/03/27 14:39:32
ヴァー
rdコマンドで俺のappフォルダを消してしまった・・・
インストーラーを使わないソフトいろいろ入れてた
/qコマンドもつけてた
やけに時間がかかると思ったらたまたま使ってたソフトを消すところで使用中ですって出て気がついた
Janeも消えてたからいまいれなおしてきたよ
810:デフォルトの名無しさん
07/03/27 15:28:50
削除はgb使ってごみ箱に移動しとけ
811:デフォルトの名無しさん
07/03/27 18:12:00
>>809
俺も以前同じことしたw
サーバーのWindows再インストールするハメになって泣いたよ
マジ悲惨だった
全米が泣いた
812:デフォルトの名無しさん
07/03/27 18:47:24
パソコン初心者
813:デフォルトの名無しさん
07/03/27 18:51:40
'gb' は、内部コマンドまたは外部コマンド、
操作可能なプログラムまたはバッチ ファイルとして認識されていません。
814:デフォルトの名無しさん
07/03/27 18:56:42
ここはプログラムを作る人の板です
815:デフォルトの名無しさん
07/03/27 18:57:57
パソコンやプログラムの使い方は板違いでスレ違い
816:デフォルトの名無しさん
07/03/27 21:22:12
,.}{.、
,.:'ナホヤ:、
/´ ̄  ̄`:ヽ.
j| / :.\ j|
. f .`i / :::::.`i f .`i
_}Ii.I{ | _________..:::::::::::| ,}I!I:{
下了 ,人 ノ:い,.:ォ''緜;;絲;;絲;;綿`ぇy'.八. 人. 下了
| :| }I i{ |i / _;:Yf,,.-−――−- ,iY_.::ヽ. ,l|. }i I{ | :|
! ::!. |:| .iHh lれ|∩l|:┌三三三三三┐:|l∩|iう:l frti. ! :| | . ::|
{-‐-} |::! l ̄├三三||: | |';';';';';_;;_';';';';';| | :||三三┤ ̄:i |.:l .{-‐-}
. | ::l {‐ } lr‐i | |f⌒i l|: | l';':'父乂父、';l | :|lf⌒i | | r‐i:| {‐::} .! :::l
| :::|. | :l || |.| l| .l:||: | |i'乂:ri‐i:i:乂'i| | :||| .l:l | l l:l i :| | :::|
. ├−┤ j,.. :! .l ニ. ! !;:三:;l|: | ll;王;lエエl;王;ll | :|l;:三 :! !. ニ.:l j :!. ├:‐::┤
| ::| | ::! .|r‐i | lf⌒i ||: | |l:干:ri‐i:i:干:l| | :||f⌒i l | r‐i:| | :| | .:::|
_| :::|_.l ..;:| __,l|__l | ||_.l:l|, ニ;l;王;lエエl;王;l;ニ ;|l|_.l:| | |__|:!__,l .;;r!';ミ;ヾ;'ゝヾ|_
マータハージマタカ
(7世紀前半 インド南西部)
817:デフォルトの名無しさん
07/03/27 22:25:18
>>814
あなたは社会生活に支障でてませんか?
818:デフォルトの名無しさん
07/03/28 05:23:18
削除ぐらいで再インストールって。バックアップ取っておくのは常識というか鉄則。
819:デフォルトの名無しさん
07/03/28 11:18:23
「削除ぐらい」ってアンタw
例えばWINDOWSフォルダの一部を削除してしまっても問題ないとでも?
実業務での定期バックアップは復旧できる最低限のみしておくのが常識だろ
キミには常識がないな
820:デフォルトの名無しさん
07/03/28 12:48:45
スルーで。
821:デフォルトの名無しさん
07/03/28 13:20:25
つかプログラマがPowerUser常用すんな
822:デフォルトの名無しさん
07/03/28 17:58:29
復旧に手間取るバックアップは意味がない。
業務ユーザならダウンタイム細小になる対策ぐらいしとけ。
823:デフォルトの名無しさん
07/03/30 21:29:59
バッチなんかプログラマが使うものじゃないでしょ
情死すが片手間で使うもんだ
824:デフォルトの名無しさん
07/03/31 15:10:52
バッチで済むところはバッチを使う。
最新レス表示スレッドの検索類似スレ一覧話題のニュースおまかせリスト▼オプションを表示暇つぶし2ch
5068日前に更新/194 KB
担当:undef