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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pass password with " to FTP

Status
Not open for further replies.

MrStar

Programmer
Sep 30, 2002
53
0
0
DK
Does anybody know how I can pass a password containing " to FTP.
Password like abcd"123.
I got an error what ever I do

I have the following ftp commands

open user username abcd"123
dir
..
..
 
How about something tlike this?

"abcd" & Chr(34) & "123"

Should work in VB. Not sure about a DOS batch file.

Thanks

John Fuhrman
Titan Global Services
 
Thanks, I have tried that, and I guess it will work, but I need to run it in dos, because I else have to have some FTP activeX object or likewise installed, and I dont always have that on my customers pc.
 
You may use the WshShell.Run method.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Then I also have to use a commandfile right ?
And then I have the same problem
 
Don't know if this will help. This is a script I was working on earlier that I have not completed yet.

What I was supposed to do when completed.

Drag-n-drop file to be transfered onto VBS.
prompt for logon
prompt for server

tranfer file to predifined location. (did not want user to change location of destinatation for my needs.)

Code:
'The script below will connect to a specific server, log in automatically, and upload the 
'dragged files automatically determining whether they need to by uploaded as binary or ASCII. 
'It's pure VBScript and uses Windows' built-in FTP client, so no additional software is needed.
'
'To use the script: 
'
'Set the username, password, server, and rootdir variables (highlighted below in red). 
'Save the script to a convenient location. Make sure you give it a .vbs extension, 
'and you name it something other than ftp.vbs. 
'
'Create a shortcut to the script file, and drag the shortcut onto the QuickLaunch bar. 


Option Explicit
'declare my variables
Dim WshShell
Dim oExec
Dim fso, ftpscrfile
Dim arg, scriptsrc, ext, tempAry
Dim username, password, server, rootdir, isBin, ftpscrfilename

'Set the constants I want to use as commands
const BINARY_FILE = "bin"
Const TEXT_FILE = "asc"

'Set the server details
username = InputBox("Enter the FTP User ID" , "DnD FTP")
password = InputBox("Enter Password" , "DnD FTP" , "Upload1")
server = InputBox("Enter Server Name or IP Address" , "DnD FTP")
rootdir = "/"

'Write out the first bit of the ftpscript
'Turn on hashing to show progress
scriptsrc = "open " & server & vbCrLf & _
username & vbCrLf & _
password & vbcrLf & _
"cd " & rootdir & vbCrLf & _
"hash" & vbCrLf

'declare the objects I 'm going to use
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set fso = WScript.CreateObject("Scripting.FileSystemObject")

'get the command-line arguments - i.e the path and filename
'of what I want to upload
for each arg in wscript.arguments

'get the extension of the file to upload
tempAry = split(arg, ".")
ext = tempAry(ubound(tempAry))

'Check for the last character of the extension being "
'and trim it off if it is
if right(ext, 1) = chr(34) then ext = left(arg, len(arg) -1)

'Assume file is binary just in case
isBin = true

select case ext
case "html", "htm", "txt", "asp", "php", "aspx", "css", "inc", "js", "vbs", "reg"
isBin = false
case else
isBin = true
end select

'Write out the ftpscript for this file
select case isBin
case true
scriptsrc = scriptsrc & BINARY_FILE & vbCrLf
case false
scriptsrc = scriptsrc & TEXT_FILE & vbCrLf
end select

'Write out ftpscript to upload file
scriptsrc = scriptsrc & "put """ & arg & """" & vbCrLf
next

'close off the ftpscript
scriptsrc = scriptsrc & "bye" & vbCrLf

'Determine the temporary path and set the filename
ftpscrfilename = WshShell.ExpandEnvironmentStrings("%Temp%") & "\ftpscript.txt"

'Write out the ftpscript
set ftpscrfile = fso.CreateTextFile(ftpscrfilename, True)
ftpscrfile.write scriptsrc
ftpscrfile.close

'call the command-line ftp client and give it the name of the ftpscript
Set oExec = WshShell.Exec("cmd /c start /WAIT /MIN ftp -s:""" & ftpscrfilename & """")

'Wait until the upload's finished.
Do While oExec.Status = 0
WScript.Sleep 100
Loop

'Wait a bit longer for safety's sake
WScript.Sleep 100

'Delete the ftpscript
fso.DeleteFile ftpscrfilename, true

'Be a nice little coder and clear down my objects
set oExec = nothing
set ftpscrfile = nothing
set fso = nothing
set WshShell = nothing


Thanks

John Fuhrman
Titan Global Services
 
And then I have the same problem
Which problem ?
You now should know how to write a quote (Chr(34)) in a ftp command file (-s option), don't you ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
No I'm not sure I understand.
If I use the -s command I read a command file, and I think this is the problem.

ftp -s:commandfile

and the commandfile has the lines

open user username abcd"123
dir

Am I misunderstanding something here ?

Please give an example if you have one
 
Back to the beginning:
WHAT IS YOUR PROBLEM ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I'm trying to make at script that can upload a file til my website, but I always get an error when I log on. The password is'nt accepted. I guess it is because the webadministrator has given me a passowrd containing then character ".

If I log on througt the program Winftp95 it is OK. Therefore I guess that it is a problem with the commandfile in dos, that can't accept the value "

 
What have you tried so far and where in your code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I think I have the code that calls ftp and send the command file, but it is the commandfilethat is the problem.

I have the following commandfile:

open user userid 1qaz"WSX
dir
cd test
put "C:\Documents and Settings\lk\Skrivebord\ftp\rep.txt"
dir
get rep.txt "C:\Documents and Settings\lk\Skrivebord\ftp\repretur.txt"
quit

But this dos'nt work even for at dos prompt
I got the message that at password is needed
 
Is the password accepted in an interactive session ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
My understanding of an interactive ftp session:
In a console window you launch ftp and you type manually the commands.
 
That is what I have tried, and it dos'nt work. I think I need some translating of the value "
 
Did you launch ftp without the -s option ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
No. I use ftp -s:filename (the file with commandlines)

I got the messages :
Connected to User name okay, need password
 
Again, what happens if you launch ftp WITHOUT the -s option and then type MANUALLY the commands ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top