Dear list, I have found a thread dealing with similar problems with a Mac, but somehow I cannot get it to work and the problem is slightly different: I am using the shell() command to execute a program from within R. The problem is that I need to execute SDKShell.bat file first that sets the environment variables for the program ogr2ogr.exe:
shell(cmd = "C:\\GDAL_1.9.2_MAPSERVER_6.2.0\\SDKShell_original.bat") Setting environment for using the GDAL and MapServer tools. Hiding the OCI plugin library. D:\R_working_directory\Koordinatenproblem>> source(.trPaths[5], echo=TRUE, max.deparse.length=150) shell( cmd="ogr2ogr -s_srs EPSG:31254 -t_srs EPSG:25832 D:\\R_working_directory\\Koordinatenproblem\\Fliessgewaesser_25832.shp D:\\R_working_directory\\Koordinatenproblem\\Fliessgewaesser.shp", invisible = FALSE, intern = TRUE ) shell(cmd="ogr2ogr -s_srs EPSG:31254 -t_srs EPSG:25832 D:\\R_working_directory\\Koordinatenproblem\\Fliessgewaesser_25832.shp D:\\R_working_director ..." ... [TRUNCATED] [1] "Der Befehl \"ogr2ogr\" ist entweder falsch geschrieben oder" "konnte nicht gefunden werden." attr(,"status") [1] 1 Warnmeldung: Ausführung von Kommando 'C:\Windows\system32\cmd.exe /c ogr2ogr -s_srs EPSG:31254 -t_srs EPSG:25832 D:\R_working_directory\Koordinatenproblem\Fliessgewaesser_25832.shp D:\R_working_directory\Koordinatenproblem\Fliessgewaesser.shp' ergab Status 1 The problem is that he cmd seems to "forget" the result of the command before, i.e. the cmd is shut between different calls by shell()!? As a result I cannot execute ogr2ogr.exe. Is there an argument or sth. to work in the same cmd-session using subsequent shell() executions from R? Thank you, best regards and have a nice Christmas, Ludwig ps: I have also tried to rewrite the .bat to set the environment variables permanently, but I did not manage that either. ----- Dipl. Geogr. Ludwig Hilger Wiss. MA Lehrstuhl für Physische Geographie Katholische Universität Eichstätt-Ingolstadt Ostenstraße 18 85072 Eichstätt -- View this message in context: http://r.789695.n4.nabble.com/Calling-a-bat-to-set-environment-variables-and-subsequent-exe-execution-from-within-R-tp4653814.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@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.