1

I am trying to run a .bat file via R, which contains input files for ASReml. The .bat file is working correctly when executed in the Windows cmd prompt, but I can't get it working via R. The code that I use was working before (some months ago) but now it's giving me errors.

The .bat file looks like this:

> batfile.univariate
      [,1]                              
 [1,] "asreml -nw31 1_Yr2WT.as"         
 [2,] "asreml -nw31 2_Yr2Fat.as"        
 [3,] "asreml -nw31 3_Yr3WT.as"         
 [4,] "asreml -nw31 4_Yr3Fat.as"        
 [5,] "asreml -nw31 5_HarvWT.as"        
 [6,] "asreml -nw31 6_FatPC.as"         
 [7,] "asreml -nw31 7_HarvDefCode.as"   
 [8,] "asreml -nw31 8_HarvMatureCode.as"
 [9,] "asreml -nw31 9_HarvSurv.as"      
[10,] "asreml -nw31 10_SRSDTD.as" 

The code that I am using to run the batfile is this:

for (i in batfile.univariate) {shell(i, intern = TRUE)}

And the error code is this:

    Warning messages:
1: In system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait,  :
  running command 'C:\WINDOWS\system32\cmd.exe /c asreml -nw31 1_Yr2WT.as' had status 1
2: In system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait,  :
  running command 'C:\WINDOWS\system32\cmd.exe /c asreml -nw31 2_Yr2Fat.as' had status 1
3: In system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait,  :
  running command 'C:\WINDOWS\system32\cmd.exe /c asreml -nw31 3_Yr3WT.as' had status 1
4: In system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait,  :
  running command 'C:\WINDOWS\system32\cmd.exe /c asreml -nw31 4_Yr3Fat.as' had status 1
5: In system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait,  :
  running command 'C:\WINDOWS\system32\cmd.exe /c asreml -nw31 5_HarvWT.as' had status 1
6: In system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait,  :
  running command 'C:\WINDOWS\system32\cmd.exe /c asreml -nw31 6_FatPC.as' had status 1
7: In system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait,  :
  running command 'C:\WINDOWS\system32\cmd.exe /c asreml -nw31 7_HarvDefCode.as' had status 1
8: In system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait,  :
  running command 'C:\WINDOWS\system32\cmd.exe /c asreml -nw31 8_HarvMatureCode.as' had status 1
9: In system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait,  :
  running command 'C:\WINDOWS\system32\cmd.exe /c asreml -nw31 9_HarvSurv.as' had status 1
10: In system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait,  :
  running command 'C:\WINDOWS\system32\cmd.exe /c asreml -nw31 10_SRSDTD.as' had status 1

Does anyone have a suggestion what I am doing wrong? Thank you very much!

  • 1
    Whichever way you look at this, the most likely issue is that cmd.exe doesn't know where to find `asreml`, or the `.as` files. `asreml` means absolutely nothing to cmd.exe, so is the location of `ASReml.exe` contained within `%PATH%`? or have you defined the current working directory as that location. If its location is in `%PATH%` or is already the current directory, then you'd need to tell `ASReml.exe` where to locate the `.as` files, by including their absolute or relative paths as necessary. If it is not, then use e.g. `"C:\Program Files\ASReml3\bin\ASReml.exe"` instead of `asreml`. – Compo May 27 '21 at 10:14

0 Answers0