0

I'm sourcing a code that need to execute an .exe file that runs a retrospective analysis for a stock assessment model.

it is when my loop reach following piece of code that it gives an error message.

shell(paste( file.path(data.path,'retro',"sms.exe"),"-nox -nohess",sep=" "), invisible = TRUE)
Warning message:
In shell(paste(file.path(data.path, "retro", "sms.exe"), "-nox -nohess",  :
  'M:/Sprat/Sprat_assessment/SMS_2023/Sprat-div-4_plus_IIIa_exploreBound2/retro/sms.exe -nox -nohess' had status error 127 

The code is running on an external driver, and I've recently updated R, using newest R-version 4.2.2, with newest versions of Rtools in Windows.

My colleagues can run the code successfully from their computer using windows, but I cannot. Any reasons why I cannot run the code and get the error message. Is their a way to set the path or allow my R to have the path in its internal enviroment?

I've already tried problems-solving from using system(), but since the code are hardwired for work processes and should not be changed this is not an optimal choice. So I need for my R execution to work with the same coding.

  • 2
    Have you tried running `M:/Sprat/Sprat_assessment/SMS_2023/Sprat-div-4_plus_IIIa_exploreBound2/retro/sms.exe -nox -nohess` outside of R at the command line? Does that work? Is the problem only when you try to run it inside of R? – MrFlick Mar 14 '23 at 15:09
  • Does ``paste0('"',file.path(data.path,'retro',"sms.exe"), '"')`` change anything? – runr Mar 14 '23 at 15:54
  • Note that in POSIX shells exit status 127 means "command not found". Does the R "shell" function actually run the command line via "shell -c ..."? If, instead, it is using that command line as the command to run that would explain the error since you're appending the arguments to the command path. – Kurtis Rader Mar 15 '23 at 16:39
  • @MrFlick Running _M:/Sprat/Sprat_assessment/SMS_2023/Sprat-div-4_plus_IIIa_exploreBound2/retro/sms.exe -nox -nohess_ outside in com. promt does not work. Furthermore paste0() is is not an optimal choice for code that are work-related and should not be changed. – fishy_stuff Mar 22 '23 at 07:38
  • @KurtisRader, as I stated above, then my colleagues can run the code successfully from their computer using windows, but I cannot - so it seems that it is my R-setup rather than anything else. – fishy_stuff Mar 22 '23 at 07:45
  • If it doesn't work at the command prompt then it doesn't seem to be related to R. You need to be able to run the program outside of R first. Once you got that, then you can figure out how to run it inside of R. – MrFlick Mar 22 '23 at 13:25

0 Answers0