Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve input from HTML and process VBScript

Status
Not open for further replies.

Rich96

Technical User
Oct 3, 2002
26
US
As a standalone script (fidm.vbs) it runs just fine and it uploads the file correctly. But when I embedd the script into an HTML page it doesn't work for me. I've pasted part of the code in this message. The message boxes are showing me the correct data but when it goes to ftp it bombs out...no errors just doesn't do it. The window pops up then closes so I don't know what it is telling me on the ftp part. Any help would be greatly appreciated. Thanks,Rich

<body>
<SCRIPT LANGUAGE=&quot;VBScript&quot;>

Sub runFIDM_onClick()
On Error Resume Next

Dim wsh
Dim tsScript
Dim fs
Dim strRemoteSite
Dim strUsrN
Dim strPssW
Dim objFolder
Dim FolderPath
Dim objFolder_Contain
Dim foundFile
Dim strFilename
Dim cdDrive
Dim intWindowStyle
Dim strFtpScriptFileName

Const TemporaryFolder = 2
Const WshHide = 0
Const WshNormalFocus = 1
Const WshMinimizedFocus = 2
Const WshMaximizedNoFocus = 3
Const WshNormalNoFocus = 4
Const WshMinimizedNoFocus = 6

'*******************************************************************************
'Retreiving values from form(id=frmGetInfo)

strUsrN = frmGetInfo.txtName.value
strPssW = frmGetInfo.txtPass.value
cdDrive = frmGetInfo.cdDrive.value
'*******************************************************************************

Set wsh = CreateObject(&quot;Wscript.Shell&quot;)
Set fs = CreateObject(&quot;Scripting.FileSystemObject&quot;)

strFtpScriptFileName = fs.BuildPath(fs.GetSpecialFolder(TemporaryFolder), fs.GetBaseName(Wscript.ScriptFullName) & &quot;.script&quot;)

strRemoteSite = &quot;myServer&quot;
intWindowStyle = WshMaximizedNoFocus

FolderPath = cdDrive
Set objFolder = fs.GetFolder(FolderPath)
Set objFolder_Contain = objFolder.Files

For Each foundFile In objFolder_Contain
strFilename = cdDrive & &quot;\&quot; & foundFile.name


'********************************************************************************
'Checking data with MsgBox
MsgBox &quot;File from cd rom: &quot; & strFilename

MsgBox &quot;From Form: &quot; & strUsrN & &quot;\&quot; & strPssW & &quot;\&quot; & cdDrive
'********************************************************************************

Set tsScript = fs.CreateTextFile(strFtpScriptFileName, True)
tsScript.WriteLine &quot;open &quot; & strRemoteSite
tsScript.WriteLine strUsrN
tsScript.WriteLine strPssW
tsScript.WriteLine &quot;hash&quot;

tsScript.WriteLine &quot;ascii&quot;
tsScript.WriteLine &quot;put &quot; & strFilename & &quot; test1&quot;

tsScript.WriteLine &quot;bye&quot;
tsScript.Close
Set tsScript = Nothing

If fs.FileExists(fs.GetSpecialFolder(1) & &quot;\ftp.exe&quot;) Then
wsh.Run fs.GetSpecialFolder(1) & &quot;\ftp.exe -s:&quot;&quot;&quot; & strFtpScriptFileName & &quot;&quot;&quot;&quot;, intWindowStyle, True
Else
wsh.Run fs.GetSpecialFolder(0) & &quot;\ftp.exe -s:&quot;&quot;&quot; & strFtpScriptFileName & &quot;&quot;&quot;&quot;, intWindowStyle, True
End If

fs.DeleteFile strFtpScriptFileName
fs.DeleteFile strFiles, True

MsgBox &quot;Upload Completed!&quot;

Set fs = Nothing

Next
End Sub
</script>

<FORM id=&quot;frmGetInfo&quot;>
<p align=&quot;center&quot;><b><font face=&quot;Tahoma&quot; size=&quot;6&quot; color=&quot;#000080&quot;><var><em><span style=&quot;letter-spacing: 3&quot;><u>Financial
Institution Data Match (FIDM)</u></span></em></var></font></b></p>
<p align=&quot;center&quot;><font color=&quot;#FF0000&quot;><i>File Extract for the Texas Child
Support Enforcement Program</i></font></p>
<hr color=&quot;#000080&quot;>
<p align=&quot;left&quot;><font color=&quot;#FF0000&quot;><i>Enter Username/Password that you use
for Silverlake access.</i></font></p>
<p align=&quot;left&quot;>Username:<input id=&quot;txtName&quot; type=&quot;text&quot; size=&quot;20&quot;></p>
<p align=&quot;left&quot;>Password:<input id=&quot;txtPass&quot; type=&quot;password&quot; size=&quot;20&quot;></p>
<p align=&quot;left&quot;>CDRom Drive Letter<input id=&quot;cdDrive&quot; type=&quot;text&quot; size=&quot;2&quot;></p>
<p align=&quot;left&quot;><input id=&quot;runFIDM&quot; type=&quot;button&quot; value=&quot;Submit&quot;>
<input type=&quot;button&quot; value=&quot;Continue&quot; name=&quot;B1&quot;></p>
<hr color=&quot;#000080&quot;>
<p align=&quot;left&quot;>Once completed you must do the following steps before selecting
continue.</p>
</form>
</body>

</html>
 
line 73 has a ; in it was this a typo, as my machine, successfully ignored the On error resume next, it showed it up

If fs.FileExists(fs.GetSpecialFolder(1) & &quot;\ftp.exe&quot;;) Then

do you want it as :

If fs.FileExists(fs.GetSpecialFolder(1) & &quot;\ftp.exe&quot;) Then

Regards
Steve Friday
 
also try

wsh.Run &quot;CMD /K &quot; & fs.GetSpecialFolder(1) & &quot;\ftp.exe -s:&quot;&quot;&quot; & strFtpScriptFileName & &quot;&quot;&quot;&quot;, intWindowStyle, True

this will keep the dos window open and may assist Regards
Steve Friday
 
also try

msgbox &quot;CMD /K &quot; & fs.GetSpecialFolder(1) & &quot;\ftp.exe -s:&quot;&quot;&quot; & strFtpScriptFileName & &quot;&quot;&quot;&quot;


after the wsh.run or before, is the command as expected Regards
Steve Friday
 
Thanks for the help sfriday. That allowed me to see what it was doing and it ended up being a directory issue. When I was calling the ftp command it didn't know where to look since I was running from a UNC path. So I changed up the wsh.Run statement as well as the strFtpScriptFileName var as follows:

strFtpScriptFileName = &quot;C:\temp\script.txt&quot; (this is standard directory structure in our environment)

and

wsh.Run &quot;C:\WINNT\system32\ftp.exe -s:&quot;&quot;&quot; & strFtpScriptFileName & &quot;&quot;&quot;&quot;, intWindowStyle, True


Thanks again for the help. Rich
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top