I am trying to change the directory in the command line from a gen_server using
os:cmd("cd d:\temp").
but nothing happense, the return is just an empty list and I remain in the same directory. any ideas?
I am trying to change the directory in the command line from a gen_server using
os:cmd("cd d:\temp").
but nothing happense, the return is just an empty list and I remain in the same directory. any ideas?
cmd() runs a sub-shell, which you're telling to change directory, then the sub-shell exits, having changed nothing about its parent process's environment.
You want to use cd() instead, if you're in the shell, or file:set_cwd() at runtime within an Erlang program.
Another option, if you want to run another program and have its working directory be different from the one Erlang is using is to pass the {cd, Dir} tuple to open_port().