I need my program go to some specific directory then run
system( ... ); there and get me back where I was before. How can I do it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Just do the
cdin yoursystemcall:The whole string gets passed to
sh(1), so you can do any normal shell things in there. Since it’s in a subshell, the working directory of your program won’t be changed.