Heiss, Christian wrote:
> Hello,
> 
> I don't know if this is the right mailing list, but well...
> 
> How can I mount something with my perl script?
> I've got always the error: mount: only root can do this
> 
> So I changed my script something like this:
> 
> #! /usr/bin/perl -w
> `su - root <password> -c 'mount -t smbfs -o  credentials=<some.file> 
> //<windows/share> /<mount/point>'`;
> 
> If I start the script in the shell as root, it works fine.
> 
> If I start the script in the shell as some other user, it asked me for 
> the password.
> 
> If I start the script in via the Internet-Browser, in the log files it 
> first asked for the password and after one second it completes to 
> "incorrect password"
> 
> How can I change my script to execute the mount command as root 
> automatically, or to mount something within my perl script???

su(8) will not do the job.  It relies on an available terminal to ask 
for the root password.  You can work around this by using an expect(1) 
script, but then you'd have to deal with tcl.

In all honestly, you'd be better off looking at sudo(1).  It's a much 
easier way to specify root access.  If you don't already have it 
installed, you can pick it up from:

     http://www.courtesan.com/sudo/

Also, if this is linux, you may be able to specify the "user" mount 
option in /etc/fstab which will let anybody mount.

-Dom

Reply via email to