- PR -

perl meets space-containing-folder-names

1
投稿者投稿内容
Oregon
ベテラン
会議室デビュー日: 2001/08/01
投稿数: 52
お住まい・勤務地: Tualatin 97062
投稿日時: 2001-09-15 01:51
suppose a perl script attempts to run an application with an argument of file
using "system" function, it fails when both folder names have spaces.
[code]
@REM='
@echo off
perl -wS %~nx0 %*
goto :eof
';
system(@ARGV);
[\code]
e.g. only [3] fails
[1] FOO.bat notepad.exe "\"C:\Program Files\FreeAmp\ReadMe.txt\""
[2] FOO.bat "\"C:\Program Files\Windows NT\Accessories\wordpad.exe\"" C:\WINNT\setup.log
[3] FOO.bat "\"C:\Program Files\Windows NT\Accessories\wordpad.exe\"" "\"C:\Program Files\FreeAmp\ReadMe.txt\""

WHY?

all cases work outside of perl.
I would appreciate if you come up with a workaround
that beats MS idio(t)syncracy in space-contaminated folders.

Oregon
ベテラン
会議室デビュー日: 2001/08/01
投稿数: 52
お住まい・勤務地: Tualatin 97062
投稿日時: 2001-09-15 02:03
oops. I goofed in [code] bracketing.
the perl script FOO.bat should read:
コード:

@REM='
@echo off
perl -wS %~nx0 %*
goto :eof
';
system(@ARGV);



and the samples runs should look like this:
コード:

[1] FOO.bat notepad.exe "\"C:\Program Files\FreeAmp\ReadMe.txt\""
[2] FOO.bat "\"C:\Program Files\Windows NT\Accessories\wordpad.exe\"" C:\WINNT\setuplog.txt
[3] FOO.bat "\"C:\Program Files\Windows NT\Accessories\wordpad.exe\"" "\"C:\Program Files\FreeAmp\ReadMe.txt\""



thanks

Oregon
ベテラン
会議室デビュー日: 2001/08/01
投稿数: 52
お住まい・勤務地: Tualatin 97062
投稿日時: 2001-09-15 02:19
hmmm... the [code] quoting is still not cooperative.

in the sample runs, all double-double quotes ("") should read ("\").
yes, a double quote (") followed by an escape (\) and another double quote (").
I swear.

my humble apologies.
Oregon
ベテラン
会議室デビュー日: 2001/08/01
投稿数: 52
お住まい・勤務地: Tualatin 97062
投稿日時: 2001-09-21 03:08
the easiest way I found so far is:
to use "cmd/b" as the first arg of perl's system() as below

コード:

FOO.bat "cmd/b" "\"C:\Program Files\Windows NT\Accessories\wordpad.exe\"" "\"C:\Program Files\FreeAmp\ReadMe.txt\""



I wonder this space-sensitivity in the first arg is a bug or feature?
Oregon
ベテラン
会議室デビュー日: 2001/08/01
投稿数: 52
お住まい・勤務地: Tualatin 97062
投稿日時: 2001-09-21 10:46
sorry, I goofed again.

should be "start/b" in place of "cmd/b"
引用:

FOO "start/b" "\"C:\Program Files\Windows NT\Accessories\wordpad.exe\"" "\"
C:\Program Files\FreeAmp\ReadMe.txt\""



(my 'back-slash' char would be your 'YEN' sign)

1

スキルアップ/キャリアアップ(JOB@IT)