From: laredotornado on
Hi,

I'm using Mac 10.6.3. In my .bash_profile, I have some directives
that mount a remote directory, such as

mount_sshfs test(a)remotehost:/opt/catalina/qa /opt/catalina/qa/

However, if I open multiple terminal windows, this command is run
again, the error message "directory is already mounted" appears, which
makes sense. How can I prevent the command from being run if the
directory is already mounted?

Thanks, - Dave


From: Jim Gibson on
In article
<fefa6043-148f-40bc-8bed-2363a5ef0815(a)m21g2000vbr.googlegroups.com>,
laredotornado <laredotornado(a)zipmail.com> wrote:

> Hi,
>
> I'm using Mac 10.6.3. In my .bash_profile, I have some directives
> that mount a remote directory, such as
>
> mount_sshfs test(a)remotehost:/opt/catalina/qa /opt/catalina/qa/
>
> However, if I open multiple terminal windows, this command is run
> again, the error message "directory is already mounted" appears, which
> makes sense. How can I prevent the command from being run if the
> directory is already mounted?

I don't use bash, nor do I have mount_sshfs on my system, but you can
redirect output to standard error to the bit bucket (null device)
instead of the screen:

mount_sshfs ... 2> /dev/null

--
Jim Gibson
From: Barry Margolin on
In article
<fefa6043-148f-40bc-8bed-2363a5ef0815(a)m21g2000vbr.googlegroups.com>,
laredotornado <laredotornado(a)zipmail.com> wrote:

> Hi,
>
> I'm using Mac 10.6.3. In my .bash_profile, I have some directives
> that mount a remote directory, such as
>
> mount_sshfs test(a)remotehost:/opt/catalina/qa /opt/catalina/qa/
>
> However, if I open multiple terminal windows, this command is run
> again, the error message "directory is already mounted" appears, which
> makes sense. How can I prevent the command from being run if the
> directory is already mounted?
>
> Thanks, - Dave

if mount | grep -q /opt/catalina/qa
then :
else mount_sshfs test(a)remotehost:/opt/catalina/qa /opt/catalina/qa
fi

--
Barry Margolin, barmar(a)alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: laredotornado on
On Jun 2, 7:47 pm, Barry Margolin <bar...(a)alum.mit.edu> wrote:
> In article
> <fefa6043-148f-40bc-8bed-2363a5ef0...(a)m21g2000vbr.googlegroups.com>,
>
>  laredotornado<laredotorn...(a)zipmail.com> wrote:
> > Hi,
>
> > I'm using Mac 10.6.3.  In my .bash_profile, I have some directives
> > that mount a remote directory, such as
>
> > mount_sshfs test(a)remotehost:/opt/catalina/qa /opt/catalina/qa/
>
> > However, if I open multiple terminal windows, this command is run
> > again, the error message "directory is already mounted" appears, which
> > makes sense.  How can I prevent the command from being run if the
> > directory is already mounted?
>
> > Thanks, - Dave
>
> if mount | grep -q /opt/catalina/qa
> then :
> else mount_sshfs test(a)remotehost:/opt/catalina/qa /opt/catalina/qa
> fi
>
> --
> Barry Margolin, bar...(a)alum.mit.edu
> Arlington, MA
> *** PLEASE post questions in newsgroups, not directly to me ***
> *** PLEASE don't copy me on replies, I'll read them in the group ***

Hey Barry, The "else" branch is always executing, regardless of
whether I have anything mounted. - Dave
From: Barry Margolin on
In article
<cb3e9a1b-7b7a-4560-9d7c-59066cf46ae1(a)d37g2000yqm.googlegroups.com>,
laredotornado <laredotornado(a)zipmail.com> wrote:

> On Jun 2, 7:47�pm, Barry Margolin <bar...(a)alum.mit.edu> wrote:
> > In article
> > <fefa6043-148f-40bc-8bed-2363a5ef0...(a)m21g2000vbr.googlegroups.com>,
> >
> > �laredotornado<laredotorn...(a)zipmail.com> wrote:
> > > Hi,
> >
> > > I'm using Mac 10.6.3. �In my .bash_profile, I have some directives
> > > that mount a remote directory, such as
> >
> > > mount_sshfs test(a)remotehost:/opt/catalina/qa /opt/catalina/qa/
> >
> > > However, if I open multiple terminal windows, this command is run
> > > again, the error message "directory is already mounted" appears, which
> > > makes sense. �How can I prevent the command from being run if the
> > > directory is already mounted?
> >
> > > Thanks, - Dave
> >
> > if mount | grep -q /opt/catalina/qa
> > then :
> > else mount_sshfs test(a)remotehost:/opt/catalina/qa /opt/catalina/qa
> > fi
>
> Hey Barry, The "else" branch is always executing, regardless of
> whether I have anything mounted. - Dave

Could you post the output of the "mount" command when you don't have
anything mounted? Maybe there's something unexpected that's matching
the grep.

P.S. Please don't quote signatures.

--
Barry Margolin, barmar(a)alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
 | 
Pages: 1
Prev: amusing job requirements
Next: To Wes (personal)