An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100602/d25f9ae5/attachment.pl>
Shell command help
5 messages · galen kaufman, Richard M. Heiberger, Joshua Wiley +1 more
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100603/52777a23/attachment.pl>
On Wed, Jun 2, 2010 at 9:40 PM, RICHARD M. HEIBERGER <rmh at temple.edu> wrote:
#Error that is returned from above code?..
'C:\Program' is not recognized as an internal or external command,
operable program or
This statement means that the Windows CMD processor does not realize that 'C:\Program Files' is a single word. ?Use the 8.3 version of the filename 'C:\progra~1' instead. ?Get the correct 8.3 name for your computer from the Windows ? dir /x command on the appropriate directory. ?Maybe you can use the ENVIRONMENT variable ?%PROGRAMFILES% directly. ?Sometimes you can use explicit quotation
just wanted to add that I routinely use environment variables directly
for paths from the Windows command prompt. shell() seems to be okay
with it too. For example this should (confirmed on on Windows
versions 5.1.2600 and 6.1.7600) open the basic calculator:
shell("%WINDIR%/System32/calc.exe")
marks "c:\Program Files\rest of path\yourprogram.exe" to get past this issue. This problem may be happening inside the program you are calling, not at your level. Uwe, a discussion of %PROGRAMFILES% and 8.3 names needs to be added to the Windows FAQ. ?I think it belongs in "Section 5 Windows Features" because it is a standard Windows feature to put software in the "Program Files" directory with an embedded blank in its name and it is a standard MSDOS feature to trip on embedded blanks. Rich ? ? ? ?[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Joshua Wiley Senior in Psychology University of California, Riverside http://www.joshuawiley.com/
On 03.06.2010 04:19, galen kaufman wrote:
Uwe,
Thank you so much for the response. I tried running the command in the format you suggested but still could not get the shell command to execute. The following is the command that I used per your suggestion and the subsequent error message.
shell('"C:\\programx.exe"' -import '"C:\\inputx.inp"' -run -quit)
This cannot work. Is this all expected to be the first argument of shell()? If so, you need to quote it as a whole.
#Error that is returned from above code?..
'C:\Program' is not recognized as an internal or external command, operable program or>batch file
Since the above command cannot work, this error message is the resukt from another call you have not given. Particularly the "c:\Program" points us to a problem with spaces in the directory "Program Files" but since you have not used that in your call from R, it must be something in C:\programx.exe or C:\inputx.inp that causes the problem, but it is not R related - unless you have used a completely different call.
Warning message:
In shell("\"C:\\programx.exe\" -import>\"C:\\input.inp\" -run -quit") :
>'"C:\programx.exe" -import "C:\input.inp" -run -quit' execution failed with error code 1
These two lines are also from two different calls. I don't see the ">" from the first line is in the second line now.... So, *please* copy and paste only code and error messages that fit to each other! Uwe Ligges
Thinking that it may be a problem with the command line I checked with developer of the program and he said that it should be the correct language. Any thoughts? Thank you again, Galen
Date: Mon, 3 May 2010 09:19:49 +0200 From: ligges at statistik.tu-dortmund.de To: leavealetter1 at hotmail.com CC: r-help at r-project.org Subject: Re: [R] Shell command help On 02.05.2010 21:55, galen kaufman wrote:
Dear R Community, I am trying to run a command line in R that will open an external program, have it import a specific input file, run the program, then close the program. The command line that I got from the developer of the model to do this looks like what you see below: c:\programx.exe -import 'inputx.inp' -run -quit I have been trying to use shell() or shell.exec() to run this in R. I can get R to open the program but I have not been able to do the rest of the steps. I have been able to open the model using :
shell('"C:\\programx.exe"')
or
shell.exec("C:\\programx.exe")
To do the rest I have been trying variations of the following:
shell('"C:\\programx.exe"' -import '"C:\\inputx.inp"' -run ?quit)
Hm, you need to pass one string to the shell (and the underlking
system()) call:
shell('"C:\\programx.exe" -import "C:\\inputx.inp" -run ?quit')
Best,
Uwe Ligges
but I am not getting anywhere. Can you provide any insight as to how to do the rest? Thank you, Galen
_________________________________________________________________ Hotmail is redefining busy with tools for the New Busy. Get more from your inbox. N:WL:en-US:WM_HMP:042010_2 [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
_________________________________________________________________ The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail. http://www.windowslive.com/campaign/thenewbusy?tile=multiaccount&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4
On 03.06.2010 06:40, RICHARD M. HEIBERGER wrote:
#Error that is returned from above code?..
'C:\Program' is not recognized as an internal or external command,
operable program or
This statement means that the Windows CMD processor does not realize that
'C:\Program Files' is a single word. Use the 8.3 version of the filename
'C:\progra~1' instead. Get the correct 8.3 name for your computer from the
Windows
dir /x
command on the appropriate directory. Maybe you can use the ENVIRONMENT
variable %PROGRAMFILES% directly. Sometimes you can use explicit quotation
marks "c:\Program Files\rest of path\yourprogram.exe" to get past this
issue.
Rich, actually, 8.3 names are not required if you use the quotes correctly, at least.
This problem may be happening inside the program you are calling, not at your level. Uwe, a discussion of %PROGRAMFILES% and 8.3 names needs to be added to the Windows FAQ. I think it belongs in "Section 5 Windows Features" because it is a standard Windows feature to put software in the "Program Files" directory with an embedded blank in its name and it is a standard MSDOS feature to trip on embedded blanks.
I would not discuss this there for educational purposes: Since correct quoting is sufficient and does not depend on the OS. Trying to be OS independent seems to be the better way in R, hence we should avoid 8.3 names / %PROGRAMFILES% that other operating systems are not aware of. Best wishes, Uwe >
Rich