From: Hylle on
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
From: Pegasus [MVP] on


"Hylle" <jens.hyllegaard(a)gmail.com> wrote in message
news:2e5512c7-7e24-4223-9a61-d6c6a1f2ac3a(a)y12g2000vbr.googlegroups.com...
> 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!

From: Tom Lavedas on
On May 25, 10:02 am, Hylle <jens.hyllega...(a)gmail.com> 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
From: Hylle on
On 25 Maj, 16:36, "Pegasus [MVP]" <n...(a)microsoft.com> wrote:
> "Hylle" <jens.hyllega...(a)gmail.com> wrote in message
>
> news:2e5512c7-7e24-4223-9a61-d6c6a1f2ac3a(a)y12g2000vbr.googlegroups.com...
>
>
>
> > 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
From: Hylle on
On 25 Maj, 17:13, Tom Lavedas <tglba...(a)verizon.net> wrote:
> On May 25, 10:02 am, Hylle <jens.hyllega...(a)gmail.com> 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