Possible solutions could be:
Starting interactive session.
sudo -s <<< "cd dir ; command"or
sudo /bin/bash -c "cd dir ; command"But I don't have /bin/bash /bin/sh /bin/su or other sudoer permissions
Changing directory before sudo is done.
cd dir ; sudo commandBut I don't have permission to enter the dir.
I need a general case pwd set (like Popen cwd), so below is not answer I can use:
sudo command /path/to/file
What I'm trying to write is python Popen wrapper with sudo=True/False option, and currently I'm trying to somehow get cwd parameter to work.
sudo cd && sudo command. – Tim Nov 27 '14 at 12:28commandon something in the directory? E.g. ifcommandweregrep regex file, just runsudo grep regex dir/file. Please provide more information in your question on the bigger picture here. And please [edit] your question for that rather than posting comments. :-) – gertvdijk Nov 27 '14 at 12:31rootdirectory, I usecommand /path/to/dir– Tim Nov 27 '14 at 12:35sudois used for running executables;cdis a shell builtin – steeldriver Nov 27 '14 at 12:51