4

I'm ftping in to an Adrive.com account to upload a backup file. I do not know the version of linux that is installed. I tried to get the version with these commands:

ftp> uname -r
Invalid command.
ftp> cat /etc/*-release
Invalid command.
ftp> lsb_release -a
Invalid command.
ftp> cat /proc/version
Invalid command.
ftp> uname -a
Invalid command.

As you can see none of them worked.

Here is my script that I'm trying to run:

ECHO open ftp://xxx:[email protected]>FTPSND.TXT
echo cd backup>>FTPSND.TXT
echo cd companyfiles>>FTPSND.TXT
echo mkdir %3>>FTPSND.TXT
echo cd %3>>FTPSND.TXT
echo option transfer binary>>FTPSND.TXT
ECHO send %1>>FTPSND.TXT
ECHO close>>FTPSND.TXT
ECHO exit>>FTPSND.TXT
winscp.com /script=ftpsnd.txt >>%2

And the error that is happening on the mkdir:

Error creating folder 'BEL'.
File or directory already exists.
(A)bort, (R)etry, (S)kip: Abort

My main problem is that if the directory does not exist, I need to create it, otherwise I skip that step and move on to the send.

Any ideas how I get around this?

EDIT

In response to Hackoo:

I failed to mention that this batch file is called from another batch file close to the end. When I used your code, I am not getting the file uploaded and the log shows:

ftp> Open ftp.adrive.com
Connected to ftp.adrive.com.
220 Username is your email address used for web interface
User (ftp.adrive.com:(none)):
331 Username OK, please send password.

230 Welcome xxxxx
ftp> prompt n
Interactive mode Off .
ftp> bin
200 TYPE changed to I.
ftp> MkDir /backup/companyfiles/IFC
550 File or directory already exists.
ftp> cd /backup/companyfiles/IFC
250 Changed directory OK.
ftp> mput D:\SSSAVES\sssbackup\TMPDIR\IFC_20160705141154.ZIP
200 PORT command OK.
150 Opening BINARY mode data connection for file IFC_20160705141154.ZIP.

It is not moving from this point and doing anything. I let it sit there for 2 hours just to make sure. The file is only 70mb in size so I doubt it would take that long.

EDIT #2

The file did eventually show up on Adrive, so I believe the ftp mput is working. It just doesn't seem to be releasing after it is sent

EDIT #3

I did change it from mput to put since I am only sending 1 file. That did not make a difference.

6
  • 1
    Why do you need to know what operating system the host is running? Commented Jul 2, 2016 at 14:47
  • @SomethingDark to know how to handle the ftp commands, so I'll know what my options are. Commented Jul 2, 2016 at 14:54
  • if not exist %3 mkdir %3 Commented Jul 2, 2016 at 16:28
  • @Aacini Ty for the response. When I tried this I got ftp> if not exist %3 mkdir %3 Invalid command. Commented Jul 2, 2016 at 16:46
  • @Aacini Ty for the response. There isn't any difference from the way I ran it, from the ftp command line, and the way you are suggesting I run it. I did put this in my script and I got the same results. The echo is outputting ftp commands and not batch commands so the if not exist will not work as an ftp command. Commented Jul 3, 2016 at 17:36

2 Answers 2

1

I created an account on ADrive.com and i created this script, just give a try

@echo off
Title Multiple file Upload by Hackoo on adrive
Color 0A
::****** Settings for FTP ************
Set FTPSERVER=ftp.adrive.com
Set USER=Your Login
Set Password=Your Password
Set LocalFolder=C:\Hackoo
Set RemoteFolder=/backupFolder
::************************************
::--- FTP commands below here ---
> ft.do echo Open %FTPSERVER%
>> ft.do echo %USER%
>> ft.do echo %Password%
>> ft.do echo prompt n
>> ft.do echo bin
>> ft.do echo lcd %LocalFolder%
>> ft.do echo MkDir %RemoteFolder%
>> ft.do echo cd %RemoteFolder%
>> ft.do echo mput "*.*"
>> ft.do echo disconnect
>> ft.do echo bye
::************************************
ftp -s:ft.do
del ft.do
Pause
Sign up to request clarification or add additional context in comments.

2 Comments

Ty for the response. I will give this a try.
I've modified my post in response to your answer. I appreciate your assistance.
0

Can you try with this vbscript and tell me if it upload or not this file with 70Mb in size :

set objShell = CreateObject("WScript.Shell")
Login = "Your Username"
'If your username contains the @ symbol, and your web browser does not support this, you can substitute for the +
Login = Replace(Login,"@","+")
Password = "Your Pass"
FTPSERVER = "ftp.server.com"
RemoteFolder = "RemoteFolderName"
FTPURL = "ftp://"& Login &":"& Password &"@"& FTPSERVER &"/"& RemoteFolder
Connect2FTP = objShell.run("Explorer "& FTPURL ,1,False)

I have done an old vbscript to deal like that

Description :

You are on a different computer than you, either with friends or in a cybercafe? You want to add, modify, delete files or folders on your FTP server? No chance, you do not have programs on hand as FTP clients like (FileZilla, CuteFTP, FlashFXP. Etc ...) to access your Private FTP server ! No problem => FTP Explorer is the solution to turn your web browser or windows explorer in your FTP client !

I'd just translate this old french version to english version !

Hope that can help you !

enter image description here

Titre = "FTP EXPLORER © Hackoo © 2016"
    Set objIE = CreateObject( "InternetExplorer.Application" )
    objIE.Navigate "about:blank"
    objIE.Document.Title = Titre
    objIE.ToolBar        = False
    objIE.Resizable      = False
    objIE.StatusBar      = False
    objIE.Width          = 320
    objIE.Height         = 390
    ScreenWidth = objIE.document.ParentWindow.screen.width 
    ScreenHeight = objIE.document.ParentWindow.screen.height
    objIE.Left = (ScreenWidth  - objIE.Width ) \ 2
    objIE.Top  = (ScreenHeight - objIE.Height) \ 2
    Do While objIE.Busy
        WScript.Sleep 200
    Loop
    objIE.Document.Body.InnerHTML = "<div align=""center""><p><h3 style='color:Red'>UserName " _
    & "<br><input type=""text"" style='color:Blue' size=""20"" " _
    & "id=""Login"" value=""put your user name here""></h3></p>"_
    & "</p><p><h3 style='color:Red'>Password<br><input type=""password"" style='color:Blue' value=""Put your password here"" size=""20"" " _
    & "id=""Password""></h3></p><p><input type=" _
    & """hidden"" id=""OK"" name=""OK"" value=""0"">" _
    & "<h3 style='color:Red'>FTP Server " _
    & "<br><input type=""text"" style='color:Blue' size=""20"" " _
    & "id=""FTPSERVER"" value=""ftp.server.com""></h3>"_
    & "<br><h3 style='color:Red'>Remote Folder "_
    & "<br><input type=""text"" style='color:Blue' size=""20"" " _
    & "id=""DossierDistant"" value=""/www""></h3></p>"_
    & "<input type=""submit"" value="" Browse your FTP Folder"" " _
    & "onclick=""VBScript:OK.Value=1""></p></div>"
    objIE.Document.Body.Style.overflow = "auto"
    objIE.Document.body.style.backgroundcolor="lightGreen"
    objIE.Visible = True
    objIE.Document.All.Password.Focus
    On Error Resume Next
    Do While objIE.Document.All.OK.Value = 0
        WScript.Sleep 200
        If Err Then    
            IELogin = Array( "", "" )
            objIE.Quit
            Set objIE = Nothing
            wscript.quit
        End if
    Loop
    On Error Goto 0
    Set ws = CreateObject("wscript.Shell")
    Login = objIE.Document.All.Login.Value
    Login = Replace(Login,"@","+")'If your username contains the @ symbol, and your web browser does not support this, you can substitute for the +
    Password = objIE.Document.All.Password.Value
    FTPSERVER = objIE.Document.All.FTPSERVER.Value
    DossierDistant = objIE.Document.All.DossierDistant.Value
    URL = "ftp://"&Login&":"&Password&"@"&FTPSERVER&"/"&DossierDistant
    Connect2FTP = ws.run("Explorer "& URL ,1,False)
    objIE.Quit
ws.Popup "Connecting to "&qq(FTPSERVER)&" is in progress ..........",3,"Connecting to "&qq(FTPSERVER)&" is in progress ..........",64
    Set objIE = Nothing
    Set ws = Nothing
    Close("iexplore.exe")
'****************************************************
Sub Close(Process)
    Set Ws = CreateObject("Wscript.Shell")
    Command = "cmd /c Taskkill /F /IM "&Process&""
    Execution = Ws.Run(Command,0,True)
End Sub
'****************************************************
Function qq(strIn) 
    qq = Chr(34) & strIn & Chr(34)
End Function
'****************************************************

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.