Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


FTP

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,3254
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> FTP
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 FTP - 6/6/2005 4:09:04 AM   
  rockocubs

 

Posts: 65
Score: 0
Joined: 4/8/2005
From:
Status: offline
I have the follwoing script which download the file's from the Mainframe. Work's great but there is one more thing i need to try and do. Using mget to get mutiple files with the wildcard * it takes the extension from the remote file, but these file do not have an extension , i would like them to be .txt extention. When i code it
mget wea* wea*.txt i get the same results as mget wea* . If this can't be done the only thing i can think of would be to do a rename of the file's with scripting and i am not sure this can be done.

Dim objFso
Dim objShell
Dim strInstructions
Dim strHost
Dim strUser
Dim strPassword

Set objFso = WScript.CreateObject("Scripting.FileSystemObject")
Set objShell = WScript.CreateObject("WScript.Shell")
strInstructions = "H:\Instructions.txt"
strHost = "xx.x.xx.xx"
strUser = "xxxxx"
strPassword = "xxxxx"

With objFso
With .CreateTextFile(strInstructions, True)
.Writeline "lcd cd.."
.Writeline "lcd h:\copybook"
.WriteLine "open " & strHost
.WriteLine "user " & strUser
.WriteLine strPassword
.WriteLine "cd .."
.WriteLine "cd pds.copybook"
' .WriteLine "prompt"
.WriteLine "mget wea* wea*.txt"
.WriteLine "close"
.WriteLine "quit"
.Close
End With
objShell.run "%windir%\system32\ftp.exe -i -n -s:" & strInstructions, 1, True
.DeleteFile strInstructions

End With
 
 
Post #: 1
 
 Re: FTP - 6/6/2005 5:51:30 AM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
did you try mget wea*.*

I just tried mget wea* wea*.txt and it worked after I hit enter on mget weasle? prompt.

(in reply to rockocubs)
 
 
Post #: 2
 
 Re: FTP - 6/6/2005 6:09:29 AM   
  rockocubs

 

Posts: 65
Score: 0
Joined: 4/8/2005
From:
Status: offline
If I try that I dont get anything because there is no file extention on the mainframe files.

(in reply to rockocubs)
 
 
Post #: 3
 
 Re: FTP - 6/6/2005 6:24:22 AM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
Ignore the wea*.*

I just tried mget wea* wea*.txt and it worked after I hit enter on mget weasle? prompt.

what i'm saing when i ftp into my site from a dos prompt and type in mget wea* wea*.txt "the file is named weasel no ext" it then prompts me with mget weasle? and I hit enter it downloads the file. When i look at the file on my local drive it download as weasle not file ext. When running your script your are not hitting enter so it is not confirming mget weasle?. Now I did not try to see if this will prompt on everyfile or just the first one.

(in reply to rockocubs)
 
 
Post #: 4
 
 Re: FTP - 6/6/2005 6:29:31 AM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
I just tried it with multiple files and it will want you to confirm on each one. Example

weasle
weasledown
weaslow

will prompt

mget weasle?

mget weasledown?

mget weaslow?

after hitting enter on each one the files were downloaded with no extension

(in reply to rockocubs)
 
 
Post #: 5
 
 Re: FTP - 6/6/2005 6:40:03 AM   
  rockocubs

 

Posts: 65
Score: 0
Joined: 4/8/2005
From:
Status: offline
I dont get an extension now but i want one on the local file of .txt but since there is not one on remote it dosen't give me one. Might not be able to d it with ftp but do a rename of the files after the ftp, not sure if you can do a mass reanme in windows with a wildcard or not.

(in reply to rockocubs)
 
 
Post #: 6
 
 Re: FTP - 6/6/2005 6:55:15 AM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
after ftp download just do a ren wea*.* wea*.txt

(in reply to rockocubs)
 
 
Post #: 7
 
 Re: FTP - 6/6/2005 9:57:12 AM   
  rockocubs

 

Posts: 65
Score: 0
Joined: 4/8/2005
From:
Status: offline
While the above script runs fine above when inserted in the html document as a sub it does not work get the scripting error as follows

line: 29
char: 2
error: Object required 'WScript'
code: 0

Any Ideas?

<html><head>
<link rel='stylesheet' href='ftp.css'>
<title>Mainframe FTP 1.0</title></head>
<script language="JavaScript">
<!-- hide
function Login(form) {
var username = form.username.value;
var password = form.password.value;
var server = form.server.value;
var local = form.local.value;
var remote = form.remote.value;
FtpScript (username,password,server,local,remote);
}

// done hiding -->

</script>
<script type="text/vbscript">
Sub FtpScript (username,password,server,local,remote)
Dim objFso
Dim objShell
Dim strInstructions
Dim strHost
Dim strUser
Dim strPassword
Dim strLocal
Dim strRemote

Set objFso = WScript.CreateObject("Scripting.FileSystemObject")
Set objShell = WScript.CreateObject("WScript.Shell")
strInstructions = "H:\Instructions.txt"
strHost = server
strUser = username
strPassword = password
strLocal = local
strrRemote = remote
With objFso
With .CreateTextFile(strInstructions, True)
.Writeline "lcd cd.."
.Writeline "lcd " & strLocal
.WriteLine "open " & strHost
.WriteLine "user " & strUser
.WriteLine strPassword
.WriteLine "cd .."
.WriteLine "cd " & strRemote
.WriteLine "mget wea* wea*.txt"
.WriteLine "close"
.WriteLine "quit"
.Close
End With
objShell.run "%windir%\system32\ftp.exe -i -n -s:" & strInstructions, 1, True
.DeleteFile strInstructions
End With
End Sub

</script>
<body bgcolor='#ffffff'>

<br><font class='title'><b>Mainframe FTP 1.0</b></font><hr>


<p><table border='0' cellpadding='0' cellspacing='1' align='center' width='98%'><form name=login>

<tr><td class='brgtcell' align='right'> Username </td>
<td class='darkcell'> <input type='text' name='username' value='' size='20' maxlength='20'>  </td></tr>

<tr><td class='brgtcell' align='right'> Password </td>
<td class='darkcell'> <input type='password' name='password' value='' size='20' maxlength='20'>  </td></tr>

<tr><td class='brgtcell' align='right'> Server </td>
<td class='darkcell'> <input type='text' name='server' value='' size='60' maxlength='120'>  </td></tr>

<tr><td class='brgtcell' align='right'> Local </td>
<td class='darkcell'> <input type='text' name='local' value='h:\' size='60' maxlength='200'>  </td></tr>

<tr><td class='brgtcell' align='right'> Remote </td>
<td class='darkcell'> <input type='text' name='remote' value='' size='60' maxlength='200'>  </td></tr>

</table>

<hr><table border='0' cellpadding='0' cellspacing='0' width='100%'><tr>
<td align='right'><input style='color:#000000' type='button' value='Connect' onClick='Login(this.form)'></td>
</tr></form></table>


</body></html>

(in reply to rockocubs)
 
 
Post #: 8
 
 Re: FTP - 6/6/2005 11:08:01 AM   
  TNO


Posts: 1397
Score: 16
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
Lower your browser security settings or put your code in an hta

(in reply to rockocubs)
 
 
Post #: 9
 
 Re: FTP - 6/7/2005 12:32:28 AM   
  rockocubs

 

Posts: 65
Score: 0
Joined: 4/8/2005
From:
Status: offline
I tried lowering browser securty to low and still same error, so is this a security error?

(in reply to rockocubs)
 
 
Post #: 10
 
 Re: FTP - 6/7/2005 12:56:18 AM   
  rockocubs

 

Posts: 65
Score: 0
Joined: 4/8/2005
From:
Status: offline
It is now working just had to remove the WScript off of WScript.CreateObject statements when in HTML.

(in reply to rockocubs)
 
 
Post #: 11
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> FTP Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts