r - Using system with windows -
i have following string i'm trying pass system on win 7 machine. should creating .git directory in repo using system not (though similar approach work on linux box windows specific problem).
system( "cd c:/users/trinker/desktop/foo2 && \"c:\\program files (x86)\\git\\bin\\git.exe\" init" ) c:/users/trinker/desktop/foo2 location of repo. c:\\program files (x86)\\git\\bin\\git.exe location of git on system.
when run above nothing happens. no message, nadda. run cat on string , paste directly command line runs, gives following message , creates .git in appropriate place.
so running...
cat("cd c:/users/trinker/desktop/foo2 && \"c:\\program files (x86)\\git\\bin\\git.exe\" init") pasting command line...
cd c:/users/trinker/desktop/foo2 && "c:\program files (x86)\git\bin\git.exe" init gives...
initialized empty git repository in c:/users/trinker/desktop/foo2/.git/ ...which good
so can outside of r same string not within r. need first string use system make run if though cat , pasted command line? answer great i'd know what's going on here can address similar circumstances in future accessing windows command line system.
give try - @ least me using system("cd blah blah && blah blah", intern = true) gave error in system(cmd, intern = t) : 'cd' not found using cd out - luckily working directory used can change working directory in r instead of in system call.
wd <- getwd() setwd("c:/users/trinker/desktop/foo2") cmd <- '"c:/program files (x86)/git/bin/git.exe" init' system(cmd, intern = t) setwd(wd) the intern parameter isn't necessary can debugging.
i'm thankful typically run on linux ;)
Comments
Post a Comment