From: Pegasus [MVP] on 27 Mar 2010 15:03 "bob123" <bob123(a)gmail.com> wrote in message news:4bae2ff6$0$23465$426a74cc(a)news.free.fr... >> >> shell.Run "tnsping " & sBase >> >> Better yet is to specify the command processor, have the application run >> minimized, and wait it to complete. For example: >> >> iReturn = shell.Run("%comspec% /c tnsping " & sBase, 2, True) > > Ok thanks > By the way, what is the signification of 2 and True ? > You need to check the various parameters of the Run method in the helpfile script56.chm which you can download from the Microsoft site. Without this file (or its equivalent) it is almost impossible to write a VB Script program.
From: Pegasus [MVP] on 27 Mar 2010 15:11 "bob123" <bob123(a)gmail.com> wrote in message news:4bae32b1$0$8904$426a74cc(a)news.free.fr... > How can I put the current sBase > in the file liste.out before running the cmd > > Thanks again Instead of using wscript.echo, you could use the writeline method of the File System Object, e.g. like so: for each sBase in aNames oOutfile.writeline "Base:", sBase iReturn = shell.Run("%comspec% /c tnsping " & sBase & " >> liste.out", 2, True Next This won't quite work because the writeline method will keep liste.out open, thus preventing the Run method from appending lines to it. You can get around the problem by splitting the task into two separate steps: for each sBase in aNames oOutfile.writeline "Base:", sBase Next oOutfile.close for each sBase in aNames iReturn = shell.Run("%comspec% /c tnsping " & sBase & " >> liste.out", 2, True Next
From: Christoph Basedau on 27 Mar 2010 20:27 Am 27.03.2010 14:20, schrieb bob123: > I would like to execute an OS command > from a list of databases in liste.txt > and get all the results in a file liste.out. > How can I do that ? > > Below my first "code" > I see a cmd quick opened but nothing else > Thanks for your help ... > > > Dim fso, infile, aNames, sBase, shell > set fso = createobject("scripting.filesystemobject") > set infile = fso.opentextfile("liste.txt",1) > Set shell = WScript.CreateObject("WScript.Shell") > > aNames = Split(infile.readall, vbnewline) > infile.close > > for each sBase in aNames > wsh.echo "Base:", sBase > shell.Run "tnsping sBase" > Next > > Off topic reply, but this a one-liner in the console-window (cmd-shell). And you'll se all the ping-tools output for /F "delims=" %A in (liste.txt) do @echo Base:%A & @tnsping %A Chris
From: Al Dunbar on 27 Mar 2010 21:14 "Christoph Basedau" <cbasedau(a)hotmail.de> wrote in message news:4baea26a$0$6762$9b4e6d93(a)newsspool3.arcor-online.net... > Am 27.03.2010 14:20, schrieb bob123: > >> I would like to execute an OS command >> from a list of databases in liste.txt >> and get all the results in a file liste.out. >> How can I do that ? >> >> Below my first "code" >> I see a cmd quick opened but nothing else >> Thanks for your help ... >> >> >> Dim fso, infile, aNames, sBase, shell >> set fso = createobject("scripting.filesystemobject") >> set infile = fso.opentextfile("liste.txt",1) >> Set shell = WScript.CreateObject("WScript.Shell") >> >> aNames = Split(infile.readall, vbnewline) >> infile.close >> >> for each sBase in aNames >> wsh.echo "Base:", sBase >> shell.Run "tnsping sBase" >> Next >> >> > > Off topic reply, but this a one-liner in the console-window (cmd-shell). > And you'll se all the ping-tools output > > > for /F "delims=" %A in (liste.txt) do @echo Base:%A & @tnsping %A Or you could capture all of that output into a log file instead of displaying it with: ( for /F "delims=" %A in (liste.txt) do @echo Base:%A & @tnsping %A ) >output.log /Al
From: Christoph Basedau on 27 Mar 2010 21:48
Am 28.03.2010 03:14, schrieb Al Dunbar: > > "Christoph Basedau" <cbasedau(a)hotmail.de> wrote: >> Am 27.03.2010 14:20, schrieb bob123: >> >>> I would like to execute an OS command >>> from a list of databases in liste.txt >>> and get all the results in a file liste.out. >>> How can I do that ? [...] >> Off topic reply, but this a one-liner in the console-window (cmd-shell). >> And you'll se all the ping-tools output >> >> for /F "delims=" %A in (liste.txt) do @echo Base:%A & @tnsping %A > > Or you could capture all of that output into a log file instead of > displaying it with: > > ( for /F "delims=" %A in (liste.txt) do @echo Base:%A & @tnsping %A ) > >output.log nice & even better if you have to check lots of servers. Chris |