Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Oct 2008 18:37:36 -0700
From:      perryh@pluto.rain.com
To:        kelly.terry.jones@gmail.com
Cc:        freebsd-questions@freebsd.org
Subject:   Re: sudo multiple commands at once without shell script
Message-ID:  <4903c9e0.kerD5YQu0ikZMn3r%perryh@pluto.rain.com>
In-Reply-To: <26face530810251811i3757db68wb7ed44faaf51444b@mail.gmail.com>
References:  <26face530810251811i3757db68wb7ed44faaf51444b@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
> How do I run multiple sudo commands at once? This fails
> because the semicolon ends the whole sudo command:
>
> > sudo whoami; whoami
> root
> user
>
> This confuses tcsh:
>
> monica:~> sudo ( whoami ; whoami )
> Badly placed ()'s.

Supposing sudo spawns a shell, something like

  ~> sudo whoami \; whoami

or

  ~> sudo "whoami; whoami"

should work.  If not, maybe try explicitly running a shell:

  ~> sudo sh -c "whoami; whoami"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4903c9e0.kerD5YQu0ikZMn3r%perryh>