How to run a root command from script?
Hullo All,
I am playing about with Fedora10 installed in VirtualBox on a Fedora9 x86_64 system. To mount a shared folder I need to run a command as root, which works OK, if done the right way. I thought it might be simpler to do it via a shell script, but that doesn't work and neither does the use of sudo, or su. The only way I have managed to get it to work without error is to use 'su -' Here is the response I got from the terminal... [terry@localhost ~]$ sudo mount -t vboxsf -o uid=terry ShareVM /home/terry/ShareVM /sbin/mount.vboxsf: mounting failed with the error: Protocol error [terry@localhost ~]$ su Password: [root@localhost terry]# mount -t vboxsf -o uid=terry ShareVM /home/terry/ShareVM /sbin/mount.vboxsf: mounting failed with the error: Protocol error [root@localhost terry]# exit exit [terry@localhost ~]$ su - Password: [root@localhost ~]# mount -t vboxsf -o uid=terry ShareVM /home/terry/ShareVM [root@localhost ~]# here is the script that doesn't work... #! /bin/sh # this script sets up the share directory sudo mount -t vboxsf -o uid=terry ShareVM /home/terry/ShareVM Can someone please point me in the right direction on this? Cheers, Terry |
Maybe try sudo su - -c 'mount -t vboxsf -o uid=terry ShareVM /home/terry/ShareVM'
|
Quote:
That worked like a bought one. Many thanks. Cheers, Terry |
All times are GMT -5. The time now is 09:33 PM. |