vbscript >> Running FTP script and waiting for answer...can I set "timeout"

by Leon » Tue, 25 Jul 2006 06:06:51 GMT

Hi

I'm running ftp "run command" every 2 minute(scheduler) to lookup new
files and download them.

It's a two step action - first buliding thel scriptfile that takes down
a filelist.
Iterating through this I find out if a new file is on the list.

Building a new scriptfile from this list with "get" command on new
files.

That works perfect .. exept for "some times" where no answer is comming
from the FTP site.
If I just waits for the answer I dont' get it and everything "hangs"
for days.

The task is scheduled by windows scheduler every 2 minute.
It is stopped if it still runs after 1 minute (because FTP not
responding some times)
This trick works for "terminating" the hanging ftp proces and normally
I'm lucky with my connection 2 minutes after again! so the problem is
not the LAN connection to the internet.

I did first run with option waitforresult=TRUE
(wshell.run "ftp -i -s:"&file_script, 0, False) and was waiting for
days some times. When "restarting" the scheduler everything ran under 3
seconds - perfect - it hangs and I don't know why.

Stop (scheduler) after 1 minutes helps me - but - Is there a "prefered"
- -"right" way to do thid task?

I'm very interested in a sample

I can give you a copy of my script for you to scan...

Cheers



vbscript >> Running FTP script and waiting for answer...can I set "timeout"

by Babu VT » Tue, 25 Jul 2006 16:07:02 GMT


Hi,

Can you post the code snippet to have a look.

rgds
Babu







vbscript >> Running FTP script and waiting for answer...can I set "timeout"

by Leon » Wed, 26 Jul 2006 05:57:13 GMT

Babu VT wrote:

'**********************************************************************
'* Create ftp scriptfile in "c:\temp"
'* to make a total fillist in "c:\temp"
'**********************************************************************
WriteLog("Creating Scriptfile...")
Set Fso = Wscript.Createobject("Scripting.FilesystemObject")
Set cmds = Fso.CreateTextFile(fil_script, True)
cmds.writeline "open "&ftp_server
cmds.writeline ftp_logon_navn
cmds.writeline ftp_password
' cmds.writeline "lcd "&ftp_tmp_mappe
cmds.writeline "ls "&ftp_filnavn&" "&fil_liste_total
cmds.writeline "bye"
cmds.close
set cmds = nothing
set Fso = nothing
tjekerror
WriteLog("Scriptfile created!")

'**********************************************************************
'* Make a fillist in "c:\temp"
'**********************************************************************



Set WshShell = Wscript.createObject("Wscript.Shell")
WriteLog("Logging on ftp-server and makes fillist...")
'WshShell.Run "ftp -i -s:"&fil_script

' here I set waitonreturn to false
WshShell.Run "ftp -i -s:"&fil_script ,0,False

'and waits 3 seconds - normally enough
Wscript.Sleep 3000
Set WshShell = Nothing
WriteLog("Logged off ftp-server!")
tjekerror


'**********************************************************************
'* check that filelist in "c:temp" exists
'**********************************************************************
Set Fso = Wscript.Createobject("Scripting.FilesystemObject")
If Not Fso.FileExists(fil_liste_total) then
Set Fso = Nothing
Writelog("ERROR! Could not find "& fil_liste_total & ",
terminating
script")
call close
else
Writelog(fil_liste_total & " created!")
end if
Set Fso = Nothing
tjekerror



Running FTP script and waiting for answer...can I set "timeout"

by Babu VT » Wed, 26 Jul 2006 17:53:21 GMT

i Leon,

Try this command to change default script engine to cscript from wscript

cscript //H:Cscript //nonlogo //s

rgds
Babu

"Leon" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...




Running FTP script and waiting for answer...can I set "timeout"

by Babu VT » Wed, 26 Jul 2006 18:02:50 GMT

orry wrong window!
"Babu VT" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...




Running FTP script and waiting for answer...can I set "timeout"

by Leon » Sun, 30 Jul 2006 06:05:39 GMT

i Babu

I don't see the point -could please you explain the "impact"?

Leon

Leon wrote:



Running FTP script and waiting for answer...can I set "timeout"

by Babu VT » Wed, 02 Aug 2006 21:58:59 GMT

i,

Did you have a chance to look at the FTP logs for further error
messages.

Also it is worth checking the ftp script file in c:\temp when the ftp
process hangs to make sure it is created properly

rgds
Babu

It happens that Leon formulated :




Running FTP script and waiting for answer...can I set "timeout"

by Leon » Mon, 07 Aug 2006 04:57:15 GMT

i

I think I found an error
the ftp script wrote the filelist to a file which schould be deletet
afterwards.
The next time ftp was trying to write to the file it sometimes
failed...
after a change whish ensured the deletion of the file ftp nomore hangs.

Thank you for your efford :)

Babu VT wrote:



Similar Threads

1. Setting FTP timeouts

How do I change the FTP timeout. I have a FTP server that sometimes gets bogged down and I want to change the FTP timeout to be longer so my PC doesn't timeout.

2. Need script to set IIS application name and session timeout

3. After script is complete, wait 15 minutes, then run again

Thanks in advance, experts.

I have a script that I would like to, whent he script has finished, it
waits for 5 or 10 or 15 minutes, then runs it again, without setting
up a scheduled task or processes - just built into the script
somehow.  Is that possible?

Also, in a separate post I asked this question, but I'll add it here
just in case.  Is there a way to attempt moving a file, if there is an
error it logs the error in a text file (already setup), but only
attempts moving the file, or only logs the error a certain number of
times, as to not fill the log with the same error multiple times?

4. Problem trying to run program from script, waiting for result

5. script that runs hidden and waits for mouse movement

Hello. Can someone post an example of how a script can detect mouse
activity and pop up an input box (like for a password) when activity is
detected? Ideally, I would want this script to run invisibly as well.

I know it would be know real security, but I am thinking more along the
lines of a creative novelty type script here.

6. Wait when running script

7. FTP using VBS script failed to copy files but succeed when run manually at command prompt

Hi,

We have a vbs script that acceee an ftp sites and ftp some files. This
vbs script is executed using SQL job via xp_cmdshell and cscript.
After we upgrade the server from Win server 2000 to 2003, the job
execute the vbs but no file is being ftped to the server. but when
executed manually using cmd prompt and cscript, the files are being
copied.

any thoughts will be appreciated. Let me know if you need more info.

these are the object being used in FTP:

' Create objects
    Set wsh = CreateObject("Wscript.Shell")
    Set fs = CreateObject("Scripting.FileSystemObject")

is there any incompatibility on these objects to win Server 2003? Is
there a known issue on scheduling SQL job in SQL 2000 in Windows
server 2003? I tried to use bat file to execute the vbs script as
CmdExec instead of TSQL via xp_cmdshell but still the ftp is not
working. By the way, it can access the ftp but not able to copy. I
tried executing the vbs in the cmd schell using the service acount to
check if there are permission problem in agent's account but the ftp
is successful. only when scheduled as SQL job, the ftp is not working.
Any thought is very appreciated.

I now tried to schedule it using windows scheduler and it is now
wroking.. is there any issue with SQL 2000 scheduler?

OS: Windows 2003 SP1
SQL 2000 SP4 (8.00.2039)

8. During VBA waiting for Message box answer problem - Excel