Before giving a definite answer, some information would be useful:
Is the script to be run by a web server through some GET/POST request (and if so does the web server run as root user?), or by a user logging in to your system or by some other method?
Is the username you are talking about a real "unix" user. i.e. a username listed in /etc/passwd who can run processes and own files and directories or just a user known to the web server (they may not coincide)?
Supposing that the user is a unix user, and the operation has to be done by a web server, then either the web server runs as root (this is not usually the case), so that you can simply do something like
su -c "mkdir $dir" $user
or you have to acquire the user's permissions through some authentication mechanism like ssh or sudo; with sudo command, for example (see man sudo), you can give limited permissions to some particular user to execute only a limited amount of commands as another user, without need to know that user's password.
Main Topics
Browse All Topics





by: selvolPosted on 2009-05-31 at 23:31:12ID: 24515359
See this it may help.
e.com/Appl e/Programm ing/ Q_2283 0615.html
http://www.experts-exchang
Regards