I want to use sudo to mount two separate network drives on a one-time basis, since my NAS device is not always on the network, so I'm not sure if adding anything to / etc / fstab is necessary.
The following code can do this, however, I do not intend to run the script from the terminal, so my sudo password hint is my problem:
#!/bin/sh
sudo mount -t cifs //10.1.1.9/Volume_1 /media/DNS323-A -ousername=user,password=pass,iocharset=utf8
sudo mount -t cifs //10.1.1.9/Volume_2 /media/DNS323-B -ousername=user,password=pass,iocharset=utf8
I need to select "run in terminal" to be able to successfully run this script from a file browser window. Thus, I would prefer to use gksudo, which will open a prompt window for entering the sudo password.
However, if the following code is used instead, I must enter the sudo password twice!
gksudo "mount -t cifs //10.1.1.9/Volume_1 /media/DNS323-A -ousername=user,password=pass,iocharset=utf8"
gksudo "mount -t cifs //10.1.1.9/Volume_2 /media/DNS323-B -ousername=user,password=pass,iocharset=utf8"
gksudo "run as sudo" :
, script , , :
gksudo -S "mount -t cifs //10.1.1.9/Volume_1 /media/DNS323-A -ousername=user,password=pass,iocharset=utf8"
sudo "mount -t cifs //10.1.1.9/Volume_2 /media/DNS323-B -ousername=user,password=pass,iocharset=utf8"
, , , , :
gksudo this{
command1
command2
command3
}
gksudo ?