Loading ...
Sorry, an error occurred while loading the content.

running shell command in the background

Expand Messages
  • Neil Zanella
    Hello, I would like to know whether there is a way in vim to run a command similar to the way it is done with :!command foo bar but such that the output of
    Message 1 of 9 , Mar 3, 2003
    • 0 Attachment
      Hello,

      I would like to know whether there is a way in vim to run a command
      similar to the way it is done with ":!command foo bar" but such that
      the output of the command is not displayed. Hence the screen does
      not change and any command output does not change the text editor
      screen. Is this possible with vim?

      Thanks,

      Neil
    • Antoine J. Mechelynck
      ... Have you tried ... (for Unix) or ... (for Dos/Windows) ? HTH, Tony.
      Message 2 of 9 , Mar 3, 2003
      • 0 Attachment
        Neil Zanella <nzanella@...> wrote:
        > Hello,
        >
        > I would like to know whether there is a way in vim to run a command
        > similar to the way it is done with ":!command foo bar" but such that
        > the output of the command is not displayed. Hence the screen does
        > not change and any command output does not change the text editor
        > screen. Is this possible with vim?
        >
        > Thanks,
        >
        > Neil

        Have you tried
        :!command foo bar >/dev/null
        (for Unix)
        or
        :!command foo bar >NUL
        (for Dos/Windows)

        ?

        HTH,
        Tony.
      • Bob Hiestand
        Message 3 of 9 , Mar 4, 2003
        • 0 Attachment
          At 00:42-0330 Tue, 4 Mar 2003, Neil Zanella wrote:

          > I would like to know whether there is a way in vim to run a command
          > similar to the way it is done with ":!command foo bar" but such that
          > the output of the command is not displayed. Hence the screen does
          > not change and any command output does not change the text editor
          > screen. Is this possible with vim?


          :let output = system('command foo bar')
        • Raymund Rimando
          ... Ray
          Message 4 of 9 , Mar 4, 2003
          • 0 Attachment
            On Tue, 2003-03-04 at 00:14, Antoine J. Mechelynck wrote:
            > Neil Zanella <nzanella@...> wrote:
            > > Hello,
            > >
            > > I would like to know whether there is a way in vim to run a command
            > > similar to the way it is done with ":!command foo bar" but such that
            > > the output of the command is not displayed. Hence the screen does
            > > not change and any command output does not change the text editor
            > > screen. Is this possible with vim?
            > >
            > > Thanks,
            > >
            > > Neil
            >
            > Have you tried
            > :!command foo bar >/dev/null
            > (for Unix)
            > or
            > :!command foo bar >NUL
            > (for Dos/Windows)
            >
            > ?
            >
            > HTH,
            > Tony.
            >

            To put the command in the background in unix:

            :!command >/dev/null 2>&1 &

            Ray
          • Neil Zanella
            ... Thank you for your reply, This solution seems better than executing a command with !:foo and redirecting with standard unix redirection mechanisms (e.g.
            Message 5 of 9 , Mar 15, 2003
            • 0 Attachment
              On Tue, 4 Mar 2003, Bob Hiestand wrote:

              > At 00:42-0330 Tue, 4 Mar 2003, Neil Zanella wrote:
              >
              > > I would like to know whether there is a way in vim to run a command
              > > similar to the way it is done with ":!command foo bar" but such that
              > > the output of the command is not displayed. Hence the screen does
              > > not change and any command output does not change the text editor
              > > screen. Is this possible with vim?
              >
              > :let output = system('command foo bar')

              Thank you for your reply,

              This solution seems better than executing a command with !:foo and
              redirecting with standard unix redirection mechanisms (e.g. > /dev/null).
              I say better because with the !:foo solution the screen still annoyingly
              scrolls down a couple of lines, and then you have to hit enter again. If
              the command is only executed once in a while then it's no big deal, but
              if it's something you must execute on the file several times a minute
              the it can become quite annoying.

              BTW, one thing is not clear to me. Since I do not need to view the
              output of the command, do I really need the 'let output = ' part
              of the command? I tried without and got an error, so is there
              a more efficient way in terms of memory usage (i.e. can we
              do the same thing without having an 'output' variable)?

              Thanks,

              Neil
            • Neil Zanella
              ... Actually this doesn t quite work for some reason. (?) Perhaps because I have a % (standing for the name of the current file in the command argument list.
              Message 6 of 9 , Mar 15, 2003
              • 0 Attachment
                On Tue, 4 Mar 2003, Bob Hiestand wrote:

                > At 00:42-0330 Tue, 4 Mar 2003, Neil Zanella wrote:
                >
                > > I would like to know whether there is a way in vim to run a command
                > > similar to the way it is done with ":!command foo bar" but such that
                > > the output of the command is not displayed. Hence the screen does
                > > not change and any command output does not change the text editor
                > > screen. Is this possible with vim?
                >
                >
                > :let output = system('command foo bar')

                Actually this doesn't quite work for some reason. (?)
                Perhaps because I have a % (standing for the name of the
                current file in the command argument list.

                Thanks,

                Neil
              • Gary Johnson
                ... Try something like this: call system( stuff before the file name .expand( % ). stuff after the file name ) HTH, Gary -- Gary Johnson |
                Message 7 of 9 , Mar 16, 2003
                • 0 Attachment
                  On 2003-03-16, Neil Zanella <nzanella@...> wrote:
                  > On Tue, 4 Mar 2003, Bob Hiestand wrote:
                  >
                  > > At 00:42-0330 Tue, 4 Mar 2003, Neil Zanella wrote:
                  > >
                  > > > I would like to know whether there is a way in vim to run a command
                  > > > similar to the way it is done with ":!command foo bar" but such that
                  > > > the output of the command is not displayed. Hence the screen does
                  > > > not change and any command output does not change the text editor
                  > > > screen. Is this possible with vim?
                  > >
                  > >
                  > > :let output = system('command foo bar')
                  >
                  > Actually this doesn't quite work for some reason. (?)
                  > Perhaps because I have a % (standing for the name of the
                  > current file in the command argument list.

                  Try something like this:

                  call system('stuff before the file name'.expand('%').'stuff after the file name')

                  HTH,
                  Gary

                  --
                  Gary Johnson | Agilent Technologies
                  garyjohn@... | Spokane, Washington, USA
                • Neil Zanella
                  ... OK, this works, so long as I remember to include a space at the end of the stuff before the file name and the suff after the file name (having the spaces
                  Message 8 of 9 , Mar 16, 2003
                  • 0 Attachment
                    On Sun, 16 Mar 2003, Gary Johnson wrote:

                    > Try something like this:
                    >
                    > call system('stuff before the file name'.expand('%').'stuff after the file name')

                    OK, this works, so long as I remember to include a space at the end of the
                    stuff before the file name and the suff after the file name (having the
                    spaces inside the expand function does not work. So, this works!

                    Thanks for your feedback!!!

                    Neil
                  • Piet Delport
                    ... [...] ... -- Piet Delport Today s subliminal thought is:
                    Message 9 of 9 , Mar 17, 2003
                    • 0 Attachment
                      On Sun, 16 Mar 2003 at 01:39:27 -0330, Neil Zanella wrote:
                      > On Tue, 4 Mar 2003, Bob Hiestand wrote:
                      >>
                      >> :let output = system('command foo bar')
                      >
                      [...]
                      >
                      > BTW, one thing is not clear to me. Since I do not need to view the
                      > output of the command, do I really need the 'let output = ' part of
                      > the command? I tried without and got an error, so is there a more
                      > efficient way in terms of memory usage (i.e. can we do the same thing
                      > without having an 'output' variable)?

                      :call system('foo')

                      --
                      Piet Delport
                      Today's subliminal thought is:
                    Your message has been successfully submitted and would be delivered to recipients shortly.