473,327 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

FTP Check for successful status

121 100+
I have this code to shell out to FTP and run a script. It waits for the script to end and then proceeds wiht the rest of the code.

However, I need to update it so that it returns an error message if any one of the steps don't finish correctly. (i.e. if the PW is bad).

Thanks for any help that could be provided.


Code:
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Private Declare Function OpenProcess Lib "kernel32" _
  4. (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
  5. ByVal dwProcessId As Long) As Long
  6.  
  7. Private Declare Function GetExitCodeProcess Lib "kernel32" _
  8. (ByVal hProcess As Long, lpExitCode As Long) As Long
  9.  
  10. Private Const STATUS_PENDING = &H103&
  11. Private Const PROCESS_QUERY_INFORMATION = &H400
  12.  
  13. Public Function ShellandWait(ExeFullPath As String, _
  14. Optional TimeOutValue As Long = 0) As Boolean
  15.  
  16.     Dim lInst As Long
  17.     Dim lStart As Long
  18.     Dim lTimeToQuit As Long
  19.     Dim sExeName As String
  20.     Dim lProcessId As Long
  21.     Dim lExitCode As Long
  22.     Dim bPastMidnight As Boolean
  23.  
  24.     On Error GoTo ErrorHandler
  25.  
  26.     lStart = CLng(Timer)
  27.     sExeName = ExeFullPath
  28.  
  29.     'Deal with timeout being reset at Midnight
  30.     If TimeOutValue > 0 Then
  31.         If lStart + TimeOutValue < 86400 Then
  32.             lTimeToQuit = lStart + TimeOutValue
  33.         Else
  34.             lTimeToQuit = (lStart - 86400) + TimeOutValue
  35.             bPastMidnight = True
  36.         End If
  37.     End If
  38.  
  39.     lInst = Shell(sExeName, vbMinimizedNoFocus)
  40.  
  41. lProcessId = OpenProcess(PROCESS_QUERY_INFORMATION, False, lInst)
  42.  
  43.     Do
  44.         Call GetExitCodeProcess(lProcessId, lExitCode)
  45.         DoEvents
  46.         If TimeOutValue And Timer > lTimeToQuit Then
  47.             If bPastMidnight Then
  48.                  If Timer < lStart Then Exit Do
  49.             Else
  50.                  Exit Do
  51.             End If
  52.     End If
  53.     Loop While lExitCode = STATUS_PENDING
  54.  
  55.     ShellandWait = True
  56.  
  57. ErrorHandler:
  58. ShellandWait = False
  59. Exit Function
  60. End Function
  61.  
  62. Function FTP_CODE()
  63. Dim FTP_SCR As String
  64.  
  65. FTP_SCR = "C:\DLU\SYSTEM\FTP\TEST.scr"
  66. Call ShellandWait("ftp.exe -s:" & FTP_SCR, 1000000)
  67. MsgBox "Process Completed"
  68. Kill "C:\DLU\SYSTEM\FTP\TEST.txt"
  69. End Function
Apr 19 '07 #1
3 2101
JHNielson
121 100+
Does anybody have any ideas they could share, or could they point me in the direction of where I could get some ideas.
Apr 19 '07 #2
vinni
1
Hi Johnson
Could u please explain the contents of the function" shellANDWait" to me.. i m new to vb and have to edit one code and i'm facing some difficulty in understanding this code..the person has used the same true copy of the function...

Kindly help as u have used it urself

Thanks
Vinni
May 18 '07 #3
Killer42
8,435 Expert 8TB
I wonder whether FTP sets ERRORLEVEL. If so, you might be able to make use of that. Something of an antiquated concept perhaps, but hey, if it works... :)
May 18 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: mshngo | last post by:
Hi, What would be the best way to check whether an istringstream object has empty buffer? I wanted to do something like: istringstream isStr(myStringContent.c_str()); while...
0
by: XML newbie: Urgent pls help! | last post by:
ok, I changed "If node.Text = "Success" " to "If Not loginDom.InnerText Is Nothing ". Now, I don't get the NullReference error but the SessionID I see on screen is concatanated one. It looks...
0
by: XML newbie: Urgent pls help! | last post by:
HI, I am working on VB.Net.My program connects to the remote host, once the login values are verified, it sends the SessionID. My problem is Although in "Logindom" variable( in the Auto window),...
3
by: VSH | last post by:
Dear Friends First i like to introduce myself. I am satish working as Oracle and Ms-SQL DBA from last 4yrs. My compnay recently introduced DB2 Database in one of our projects. I installed...
2
by: sethwai | last post by:
Hi, I have a nightly script that executes inplace reorgs allow write access for several tables after a previous script does a large number of delete operations. It usually has been executing...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.