output to cmd with | symbol

H

Hylle

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 Computer

P

Pegasus [MVP]

"Hylle" <[email protected]> wrote in message
news:2e5512c[email protected]

> 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 Computer

T

Tom Lavedas

On May 25, 10:02 am, Hylle <[email protected]> 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 Computer

H

Hylle

On 25 Maj, 16:36, "Pegasus [MVP]" <[email protected]> wrote:

> "Hylle" <[email protected]> wrote in message
>
> news:[email protected]
>
>
>
>

> > 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 Computer

H

Hylle

On 25 Maj, 17:13, Tom Lavedas <[email protected]> wrote:

> On May 25, 10:02 am, Hylle <[email protected]> wrote:
>
>
>
>

> > 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 Computer

Top