Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

SYSTEMQQ call with quotes

a_leonard
新手
979 次查看

I'm trying to use SYSTEMQQ with quotes for the command and arguments and it doesn't seem to work.  It's OK if either the command or the arguments are quoted, but not both.

result = systemqq ( ' "C:\Program Files (x86)\Notepad++\notepad++" "c:\temp\new file.txt" ' )

gives me the error:

'C:\Program' is not recognized as an internal or external command, operable program or batch file.

The following commands work as expected:

result = systemqq ( ' dir "c:\temp\new file.txt" ' )

result = systemqq ( ' "C:\Program Files (x86)\Notepad++\notepad++" c:\temp\new_file.txt ' )

How do I use this if both the command and the arguments have spaces?

0 项奖励
4 回复数
TimP
名誉分销商 III
979 次查看

In Fortran, a pair of quote marks is taken as a single one:

https://software.intel.com/sites/products/documentation/doclib/stdxe/2013/composerxe/compiler/fortran-mac/GUID-EC61DE8C-A087-4984-9CA5-5199137730AB.htm

so you should be able to get 2 quotes (if that's what you wanted) from 2 pairs of quotes (I suppose "" "")

0 项奖励
mecej4
名誉分销商 III
979 次查看

Try the following, which sidesteps the rules regarding quotes within quotes.

use ifport
character*132 cmd
integer iret
write(cmd,10)'C:\Program Files (x86)\Notepad++\notepad++','C:\temp\new file.txt'
10 format('""',A,'" "',A,'""')
iret=systemqq(cmd)

 

0 项奖励
a_leonard
新手
979 次查看

The problem was not with my formatting, it was with the command interpreter.  Apparently I need quotes around my string with multiple sets of quotes.

..., string is processed by examining the first character to verify whether or not it is an opening quotation mark. If the first character is an opening quotation mark, it is stripped along with the closing quotation mark. Any text following the closing quotation marks is preserved.

This works

    result = systemqq ( '""C:\Program Files (x86)\Notepad++\notepad++" "c:\temp\new file.txt""' )    

 

0 项奖励
mecej4
名誉分销商 III
979 次查看

The quotation is, if I am not mistaken, taken from the MSDN documentation for the XP command processor, CMD.

Seen by itself,  it is a bit humorous, is it not? "If the first character is an opening quotation mark"? There are no separate characters for "opening" and "closing" quotation marks, so whether a quotation mark is "opening" or "closing" is determined by context; a first character in a string, if a quotation mark, must be an opening quotation mark.

There is a similar ambiguity about "the closing quotation mark". Is that the first non-escaped matching quote that is encountered by scanning forward, or are you supposed to do a reverse scan from the end of the string?

0 项奖励
回复