Re: How to read text files on remote servers without by hyk108
hyk108
Mon Mar 24 16:54:22 CDT 2008
On Mar 21, 4:08=A0pm, Hoa.Hoa.Ngu...@gmail.com wrote:
> On Mar 19, 4:16=A0pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
>
>
>
>
>
> > <Hoa.Hoa.Ngu...@gmail.com> wrote in message
>
> >news:df8d01cc-320b-46c1-a5c2-3df747201d55@m36g2000hse.googlegroups.com...=
>
> > > 1) We have a script that maps and unmaps drives.
> > > This script is an audit script. =A0So it is called say from Box1 to
> > > BoxA, BoxB, BoxZ etc...
> > > To find out where BoxA-BoxZ have been running backups, the script
> > > interrogates
> > > the backup logs on BoxA-BoxZ.
>
> > > To read the BoxA-BoxZ the script maps a drive ( V: in this instance)
>
> > > objNetwork.MapNetworkDrive "V:", "\\" & strComputer & "\" & "C$", ,
> > > strUser, strPwd
> > > and open to read the back up logs
> > > =A0 =A0 =A0strFilePath =3D "V:\Program Files\Tivoli\TSM\baclient
> > > \dsmsched.log"
>
> > > When finished the drive gets disconnected/unmapped.
>
> > > If there multiple script jobs running concurrently, this could be a
> > > problem as there could be a job querying the log file as the volume
> > > could have been dismounted from another job.
>
> > > What would be the best way to read the log on a server without
> > > mounting the drives?
>
> > > 2) Another reason for mounting the drives,
> > > there are some windows commands like "ipconfig" we usually run the
> > > command, save as a text file
> > > errReturn =3D objProc.Create ("cmd.exe /c ipconfig > C:\temp
> > > \ipview.txt", Null, Null, intPID)
>
> > > Is there a better way of executing command and read the output
> > > directly without having to creating an extra file?
>
> > 1) You could use the objFSO object to open a file, using the
> > =A0 =A0 =A0UNC naming convention ("\\Server\Share\FileName.Ext").
> > 2) You could use the .exec method to read the output from ipconfig
> > =A0 =A0 =A0without an intermediate file:
> > Set ObjWshShell =3D WScript.CreateObject("WScript.Shell")
> > Set ObjExec =3D ObjWshShell.Exec("ipconfig.exe /all")
> > Do While Not ObjExec.StdOut.AtEndOfStream
> > =A0WScript.Echo ObjExec.StdOut.ReadLine 'Read a line
> > Loop- Hide quoted text -
>
> > - Show quoted text -
>
> Thank you Pegasus and Corey and everyone for their answers/suggestions
> for my questions.- Hide quoted text -
>
> - Show quoted text -
Thank you all, I was able to resolve the it this way:
Set args=3DWScript.Arguments
strComputer =3D args.Item(0)
strUser =3D args.Item(1)
strPwd =3D args.Item(2)
Set Wsh =3D WScript.CreateObject("WScript.Shell")
Wsh.run ("cmd /c net use \\" & strComputer & "\C$ /user:" & """" &
strUser & """" & " " & """" & strPwd & """")
Wsh.run ("cmd /c copy \\" & strComputer & "\C$\Temp\test.txt C:
\temp")
Wsh.run ("cmd /c net use " & strComputer & "\C$ /d")
Also, objExecObject.StdOut was very helpful.
Thanks again!