Windows Vista Forums

output to cmd with | symbol

  1. #1


    Hylle Guest

    output to cmd with | symbol

    Hi.

    I am trying to call a cmd with some parameters. Unfortunately one of
    them is the | symbol.
    Here is the call i make:

    cmd="cmd /c" & chr(34) & "Echo WEBTST" & vbtab & "Check Backup status"
    & vbtab & status & vbtab & "Backup completed ok" & chr(124) &
    "files=" & files & ", folders=" & folders &", bytes=" & bytes &
    chr(34) & "|c:\repbcklog\send_nsca.exe -H nagios2 -c C:\repbcklog
    \send_nsca.cfg"
    wscript.echo cmd

    The call is trying to send input to the send_nsca.exe program, which
    requires TAB as the delimiter, and the chr(124) is the pipe symbol,
    the other pipe sign is working fine. I have tested including the ^
    sign before the chr(124). If i try to enter the command manually on a
    command prompt it works fine, but if it is the vbscript that does it,
    it complains that "files" is not a command. How do I escape the | sign
    so it works?

    Any hints?

    regards

    Jens Hyllegaard

      My System SpecsSystem Spec

  2. #2


    Pegasus [MVP] Guest

    Re: output to cmd with | symbol



    "Hylle" <jens.hyllegaard@newsgroup> wrote in message
    news:2e5512c7-7e24-4223-9a61-d6c6a1f2ac3a@newsgroup

    > Hi.
    >
    > I am trying to call a cmd with some parameters. Unfortunately one of
    > them is the | symbol.
    > Here is the call i make:
    >
    > cmd="cmd /c" & chr(34) & "Echo WEBTST" & vbtab & "Check Backup status"
    > & vbtab & status & vbtab & "Backup completed ok" & chr(124) &
    > "files=" & files & ", folders=" & folders &", bytes=" & bytes &
    > chr(34) & "|c:\repbcklog\send_nsca.exe -H nagios2 -c C:\repbcklog
    > \send_nsca.cfg"
    > wscript.echo cmd
    >
    > The call is trying to send input to the send_nsca.exe program, which
    > requires TAB as the delimiter, and the chr(124) is the pipe symbol,
    > the other pipe sign is working fine. I have tested including the ^
    > sign before the chr(124). If i try to enter the command manually on a
    > command prompt it works fine, but if it is the vbscript that does it,
    > it complains that "files" is not a command. How do I escape the | sign
    > so it works?
    >
    > Any hints?
    >
    > regards
    >
    > Jens Hyllegaard
    Let's have a look at the script line that actually invokes the command!


      My System SpecsSystem Spec

  3. #3


    Tom Lavedas Guest

    Re: output to cmd with | symbol

    On May 25, 10:02*am, Hylle <jens.hyllega...@newsgroup> wrote:

    > Hi.
    >
    > I am trying to call a cmd with some parameters. Unfortunately one of
    > them is the | symbol.
    > Here is the call i make:
    >
    > cmd="cmd /c" & chr(34) & "Echo WEBTST" & vbtab & "Check Backup status"
    > & vbtab & status & vbtab & "Backup completed ok" *& chr(124) &
    > "files=" & files & ", folders=" & folders &", bytes=" & bytes &
    > chr(34) & "|c:\repbcklog\send_nsca.exe -H nagios2 -c C:\repbcklog
    > \send_nsca.cfg"
    > wscript.echo cmd
    >
    > The call is trying to send input to the send_nsca.exe program, which
    > requires TAB as the delimiter, and the chr(124) is the pipe symbol,
    > the other pipe sign is working fine. I have tested including the ^
    > sign before the chr(124). If i try to enter the command manually on a
    > command prompt it works fine, but if it is the vbscript that does it,
    > it complains that "files" is not a command. How do I escape the | sign
    > so it works?
    >
    > Any hints?
    >
    > regards
    >
    > Jens Hyllegaard
    It appears to me that there is a problemwith the two Chr(34)s. They
    are creating an invalid statement. In addition, I found that the
    escape character needs to be escaped, so that it requires THREE carats
    to make the statement work. Try this ...

    cmd="cmd /c" & "Echo WEBTST" & vbtab & "Check Backup status" _
    & vbtab & status & vbtab & "Backup completed ok^^^|" _
    & "files=" & files & ", folders=" & folders &", bytes=" & bytes _
    & "|c:\repbcklog\send_nsca.exe -H nagios2 -c C:\repbcklog
    \send_nsca.cfg"
    wscript.echo cmd
    _____________________
    Tom Lavedas

      My System SpecsSystem Spec

  4. #4


    Hylle Guest

    Re: output to cmd with | symbol

    On 25 Maj, 16:36, "Pegasus [MVP]" <n...@newsgroup> wrote:

    > "Hylle" <jens.hyllega...@newsgroup> wrote in message
    >
    > news:2e5512c7-7e24-4223-9a61-d6c6a1f2ac3a@newsgroup
    >
    >
    >

    > > Hi.
    >

    > > I am trying to call a cmd with some parameters. Unfortunately one of
    > > them is the | symbol.
    > > Here is the call i make:
    >

    > > cmd="cmd /c" & chr(34) & "Echo WEBTST" & vbtab & "Check Backup status"
    > > & vbtab & status & vbtab & "Backup completed ok" *& chr(124) &
    > > "files=" & files & ", folders=" & folders &", bytes=" & bytes &
    > > chr(34) & "|c:\repbcklog\send_nsca.exe -H nagios2 -c C:\repbcklog
    > > \send_nsca.cfg"
    > > wscript.echo cmd
    >

    > > The call is trying to send input to the send_nsca.exe program, which
    > > requires TAB as the delimiter, and the chr(124) is the pipe symbol,
    > > the other pipe sign is working fine. I have tested including the ^
    > > sign before the chr(124). If i try to enter the command manually on a
    > > command prompt it works fine, but if it is the vbscript that does it,
    > > it complains that "files" is not a command. How do I escape the | sign
    > > so it works?
    >

    > > Any hints?
    >

    > > regards
    >

    > > Jens Hyllegaard
    >
    > Let's have a look at the script line that actually invokes the command!
    Sorry, I thought I had put it in.

    here it is, pretty simple:

    result = objShell.run (cmd)

    I then check the value of result

    Regards

    Jens

      My System SpecsSystem Spec

  5. #5


    Hylle Guest

    Re: output to cmd with | symbol

    On 25 Maj, 17:13, Tom Lavedas <tglba...@newsgroup> wrote:

    > On May 25, 10:02*am, Hylle <jens.hyllega...@newsgroup> wrote:
    >
    >
    >

    > > Hi.
    >

    > > I am trying to call a cmd with some parameters. Unfortunately one of
    > > them is the | symbol.
    > > Here is the call i make:
    >

    > > cmd="cmd /c" & chr(34) & "Echo WEBTST" & vbtab & "Check Backup status"
    > > & vbtab & status & vbtab & "Backup completed ok" *& chr(124) &
    > > "files=" & files & ", folders=" & folders &", bytes=" & bytes &
    > > chr(34) & "|c:\repbcklog\send_nsca.exe -H nagios2 -c C:\repbcklog
    > > \send_nsca.cfg"
    > > wscript.echo cmd
    >

    > > The call is trying to send input to the send_nsca.exe program, which
    > > requires TAB as the delimiter, and the chr(124) is the pipe symbol,
    > > the other pipe sign is working fine. I have tested including the ^
    > > sign before the chr(124). If i try to enter the command manually on a
    > > command prompt it works fine, but if it is the vbscript that does it,
    > > it complains that "files" is not a command. How do I escape the | sign
    > > so it works?
    >

    > > Any hints?
    >

    > > regards
    >

    > > Jens Hyllegaard
    >
    > It appears to me that there is a problemwith the two Chr(34)s. *They
    > are creating an invalid statement. *In addition, I found that the
    > escape character needs to be escaped, so that it requires THREE carats
    > to make the statement work. *Try this ...
    >
    > cmd="cmd /c" & "Echo WEBTST" & vbtab & "Check Backup status" _
    > & vbtab & status & vbtab & "Backup completed ok^^^|" _
    > & "files=" & files & ", folders=" & folders &", bytes=" & bytes _
    > & "|c:\repbcklog\send_nsca.exe -H nagios2 -c C:\repbcklog
    > \send_nsca.cfg"
    > wscript.echo cmd
    > _____________________
    > Tom Lavedas
    Hi.

    Thanks that did it. It was due to the triple ^

    Here is what is working for me now.

    cmd="cmd /c" & chr(34) & "Echo WEBTST" & vbtab & "Check Backup status"
    & vbtab & status & vbtab & "Backup completed ok^^^" & chr(124) &
    "files=" & files & ", folders=" & folders &", bytes=" & bytes &
    chr(34) & "|c:\repbcklog\send_nsca.exe -H nagios2 -c C:\repbcklog
    \send_nsca.cfg"
    test = objShell.run (cmd)
    wscript.echo cmd

      My System SpecsSystem Spec


output to cmd with | symbol
Similar Threads
Thread Forum
@ symbol won't work Vista mail
Re: Why does the > symbol appear on some replies but not on others? Vista mail
Symbol definition Vista mail
Calendar Symbol Vista mail
Euro symbol Vista mail