title: shell script- How can I use gksudo to perform consecutive sudo operations with only one password prompt?
body: <p>I want to use sudo to mount two separate network drives on an ad-hoc basis as my NAS device is not always on line, so I am not convinced that adding anything to /etc/fstab is necessary.</p>
  
  <p>The following code is able to achieve this, however I do not intend to run the script from a terminal, thus the sudo password prompt is my issue:</p>
  
  <pre><code>#!/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
  </code></pre>
  
  <p>I need to select "run in terminal" to be able to successfully run that script from a file browser window.  Thus I would prefer to use gksudo, which will open a prompt window for me to enter the sudo password.</p>
  
  <p>However, if I instead use the following code I have to type the sudo password twice!</p>
  
  <pre><code>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"
  </code></pre>
  
  <p>At this point I tried to be smart and use the gksudo option to "run as sudo" as follows,
  however only the first drive is mounted like the first script above would fail silently if not run from a terminal:</p>
  
  <pre><code>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"
  </code></pre>
  
  <p>What I'd really like to be able to do is the following, but I'm not sure if it's possible:</p>
  
  <pre><code>gksudo this{
  command1
  command2
  command3
  }
  </code></pre>
  
  <p>Is it just me or does gksudo have a short memory?</p>