Mailinglist Archive: opensuse (3506 mails)

< Previous Next >
Re: [opensuse] ssh to a machine, run bash with some commands, keep bash running?
  • From: "Dr. Werner Fink" <werner@xxxxxxx>
  • Date: Mon, 25 Sep 2006 12:14:49 +0200
  • Message-id: <20060925101449.GA19163@xxxxxxxxxxxxx>
On Sun, Sep 24, 2006 at 09:01:05AM -0400, fdr-os@xxxxxxxxxxxxxx wrote:
>
> screen is great for that, but that's not quite what I'm looking for...
> maybe I phrased my original post badly...
>
> My basic problem is that when I run:
>
> # bash -c 'command1;command2;command3'
>
> bash does those commands, then exits. I want bash to do those commands
> and not exit, without having to put the commands into a file and use
> --rcname.

The option `-c' is not designed for an interactive bash but for
executing the string provided to that option. If there is no
command left in the string the short `script' given by the string
does exit as usual. As you can see from manual page, the string
is like script because if you add a second string after the option
-c and its string this is set as positional parameters strarting
with `$0':

bash -c 'echo $0; echo $@' foo bar

Now knowing this you may use something like this

bash -c 'echo $0; echo $@; exec -l bash' foo bar

... the option -l makes the second bash a login shell.


Werner

--
"Having a smoking section in a restaurant is like having
a peeing section in a swimming pool." -- Edward Burr
---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >