#172332 - 2007-01-03 10:05 AM
Quote needed for script job
|
Ashpoint
Starting to like KiXtart
Registered: 1999-08-27
Posts: 192
Loc: Sydney, NSW, Australia
|
Anyone want to do a small paid job? I reckon a Kix script using SENDKEYs would do the job and given a price, I'm sure the client will pay to have it done.
I need a script (Kix, Windows script, etc) that will do the following pseudo code as a timed event...
Start Internet Explorer Run an executable on a known web site Wait till the process is done (maybe the delay might be determined by observation) When done, close Internet Explorer.
Background: We presently FTP a zip file containing customer names, addresses and invoice details to the client website The web masters have given us a software that unzips the file and "absorbs" the data into the web site. We presently run the following DOS batch file each evening - works a treat except we end up with Internet Explorer screens staying open on the desktop.
FTP -s:client.txt START /WAIT IEXPLORE http://123.123.123.123/client/invoice.cfc? EXIT
|
Top
|
|
|
|
#172342 - 2007-01-03 04:09 PM
Re: Quote needed for script job
[Re: NTDOC]
|
Mart
KiX Supporter
Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
|
Untested but this might work.
Break on
$ie = "C:\Program Files\Internet Explorer\iexplore.exe"
$source = "http://123.123.123.123/client/invoice.cfc"
$destination = "c:\invoice.cfc"
Shell $ie "http://www.somesite.com/someexe"
FTPget($source, $destination)
;Function: FTPget()
;
;Authors: Lonkero
; kdyer
;
;Version: 1.1 (6th of December 2002)
;
;Action: gets file from ftp or http server and saves it in specified file
;
;Syntax: FTPget("URL", "TARGET", "USERNAME", "PASSWORD")
;
;Parameters:
; URL - full url to the file to get
; TARGET - full path to file where to save
; USERNAME- optional, specifies username to use in connection
; PASSWORD- optional, specifies password to use in connection
;
;Returns:
; Nothing or errorcode on error.
;
; on error errorcodes returned and set:
; 1 -failed to initialize http-object
; 2 -failed to initialize ADODB-object
; 3 -failed to open connection
; 4 -ADO write failed
; 5 -save to file failed
;
;Dependencies:
; IE5 or higher
;
;Remarks:
; if file exists, it will be overwritten.
; not sure about the ado, dependency?
;
;Example:
; "Downloading TypelibViewer, Please standby..."
; if FTPget("http://www.rwksystems.com/files/TypeLibViewer.exe","%temp%\typelibViewer.exe")
; "error occured:" @error
; else
; "Download complete. file is saved in %temp% as typelibViewer.exe"
; endif
;
;Source:
Function FTPget($sURL, $sTargetFile, optional $sUser, optional $sPass)
Dim $oFTP, $oStream
$sUser=""+$sUser
$oFTP = CreateObject("Microsoft.XMLHTTP")
If @error $ftpget=1 Exit 1 EndIf
$oStream = CreateObject("ADODB.Stream")
If @error $ftpget=2 Exit 2 EndIf
If $sUser
$oFTP.Open("GET", $sURL, Not 1, $sUser, $sPass)
Else
$oFTP.Open("GET", $sURL, Not 1)
EndIf
If @error $ftpget=3 Exit 3 EndIf
$oFTP.Send
$oStream.Type = 1
$oStream.Mode = 3
$oStream.Open
$oStream.Write($oFTP.responseBody)
If @error $ftpget=4 Exit 4 EndIf
$oStream.SaveToFile($sTargetFile, 2)
If @error $ftpget=5 Exit 5 EndIf
$oStream.Close
EndFunction
_________________________
Mart
- Chuck Norris once sold ebay to ebay on ebay.
|
Top
|
|
|
|
#172351 - 2007-01-04 01:27 AM
Re: Quote needed for script job
[Re: NTDOC]
|
Ashpoint
Starting to like KiXtart
Registered: 1999-08-27
Posts: 192
Loc: Sydney, NSW, Australia
|
I'm at liberty to offer payment by my client so happy to do that.
I also seem to have given the wrong slant on the issue. The FTP process works fine and I'm not inclined to change that.
The bit I can't seem to master is the actual closing of the IEXPLORE window after it has done the job.
The line of code saying: START /WAIT IEXPLORE http://123.123.123.123/client/invoice.cfc? works beautifully but we end up with IEXPLORE screens litered all over the desktop.
There is no command line switch that will close IEXPLORE after it has done the job. In other words we need a script to start IE, run the http://123 stuff, THEN CLOSE IE! Wouldn't it be good to have something like a /EXIT command that would do the job?
Edited by Ashpoint (2007-01-04 01:29 AM)
|
Top
|
|
|
|
#172352 - 2007-01-04 02:03 AM
Re: Quote needed for script job
[Re: Ashpoint]
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11623
Loc: CA
|
Call something like this when you're sure the process is completed.
If Not @LogonMode
Break On
Else
Break Off
EndIf
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('NoMacrosInStrings','On')
$SO=SetOption('WrapAtEOL','On')
EndProc('IEXPLORE.EXE')
Function EndProc($Proc)
DIM $Process
For Each $Process In GetObject("winmgmts:/root/cimv2").ExecQuery("Select * from Win32_Process where Name= " +'"'+$Proc+'"')
$Process=$Process.Terminate
Next
Exit @ERROR
EndFunction
|
Top
|
|
|
|
#172353 - 2007-01-04 03:33 AM
Re: Quote needed for script job
[Re: NTDOC]
|
Ashpoint
Starting to like KiXtart
Registered: 1999-08-27
Posts: 192
Loc: Sydney, NSW, Australia
|
That's VERY elegant and generous. I will have access to the client's server during the weekend and am looking forward to studying your solution.
I'll report back next week.
Thanks again... Michael
|
Top
|
|
|
|
#172355 - 2007-01-04 05:41 AM
Re: Quote needed for script job
[Re: Ashpoint]
|
Ashpoint
Starting to like KiXtart
Registered: 1999-08-27
Posts: 192
Loc: Sydney, NSW, Australia
|
I couldn't wait till the weekend and tried the code on my own computer. It works a treat.
Excellent work and thank you.
Michael
|
Top
|
|
|
|
#172420 - 2007-01-05 02:22 AM
Re: Quote needed for script job
[Re: Björn]
|
Ashpoint
Starting to like KiXtart
Registered: 1999-08-27
Posts: 192
Loc: Sydney, NSW, Australia
|
Thank you Bjorn for the reminder and excellent suggestion.
I have today made a donation to the Australian National Breast Cancer Foundation - my wife is a breast cancer survivor!
Thanks again to Mart, NTDOC and all who assisted.
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
2 registered
(morganw, mole)
and 414 anonymous users online.
|
|
|