WatchDirectory home page
WatchDirectory Startseite (Deutsche Version)
Site WatchDirectory (Français)
  Welcome, Guest. Please Login or Register
YaBB - Yet another Bulletin Board
   
  HomeHelpSearchLoginRegister  
 
Page Index Toggle Pages: 1
How can I send files to SFTP Server? (Read 8817 times)
kchrist
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 3
How can I send files to SFTP Server?
Apr 13th, 2005 at 1:04pm
 
I'm using WatchDirectory 3.2.6 evaluation version.

Is there any way to send files from a WatchDirectory to a Secure FTP Server?

Best regards,
kchrist
Back to top
 
 
IP Logged
 
erubiinsky
Ex Member


Re: How can I send files to SFTP Server?
Reply #1 - Apr 13th, 2005 at 2:36pm
 
Use ssh-keygen to set up a public key for automatic logins.

The use SCP, instead of SFTP in the form:
  scp my_file user@host:\mydir

Hope this helps.
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: How can I send files to SFTP Server?
Reply #2 - Apr 13th, 2005 at 3:30pm
 
Another possibility...

Visit http://www.watchdirectory.net/beta and join the beta program for watchDirectory version 4.  A new FTP plugin is almost ready for beta-test and allows FTP, SFTP and FTPS uploads.

Btw, WD v4 will be a free upgrade for customers that bought a previous version less than 1 year ago.

Gert
Back to top
 

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
kchrist
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 3
Re: How can I send files to SFTP Server?
Reply #3 - Apr 13th, 2005 at 4:01pm
 
Quote:
Use ssh-keygen to set up a public key for automatic logins.

The use SCP, instead of SFTP in the form:
 scp my_file user@host:\mydir

Hope this helps.


Sorry for that...but what is SCP?
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: How can I send files to SFTP Server?
Reply #4 - Apr 13th, 2005 at 4:04pm
 
I guess it is WinSCP: http://winscp.net/eng/index.php.
Gert
Back to top
 

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
kchrist
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 3
Re: How can I send files to SFTP Server?
Reply #5 - Apr 13th, 2005 at 4:15pm
 
Quote:
I guess it is WinSCP: http://winscp.net/eng/index.php.
Gert


OK...
I'm using now a Sample bat which is the following...:


@echo off
GOTO EndRemarks

After you changed this script, you should remove everything BEFORE the line that reads "@echo off" above.

This bat-file will automatically ftp new files to an ftp-server.
It uses the ftp program as provided by Microsoft.

This .bat file has some simple checks to see if you have configured it properly.
When a check fails, a message will popup to warn you.
These checks can be disabled by setting the DEBUGBAT option to N.

:EndRemarks
REM ==================================================
REM = CHANGE THE STATEMENTS BELOW FOR YOUR SITUATION =
REM ==================================================
REM DEBUGBAT
REM    If this option is set to Y, this .bat file will perform some
REM    simple checks to see if it is configured properly.
REM    If a problem is detected, a message will popup to warn you.
REM    When you are satisfied with your settings, you should
REM    set this option to a value other than Y.
SET DEBUGBAT=Y

rem
rem FTPSERVER
rem    the ftp server name
rem    if you need to include a port number, separate the server and port
rem    with a space - not a colon (Smiley

SET FTPSERVER=195.XXX.XXX.XXX

rem
rem FTPUSER
rem    The userid to use for logging in

SET FTPUSER=xxx

rem
rem FTPPASS
rem    The password to use for logging in

SET FTPPASS=xxxxxxxx

rem
rem FTPDIR
rem    The directory on the ftp-server where
rem    the files should be stored

SET FTPDIR=/xxxxx

rem
rem FTPTEMP
rem    Enter the name of a directory where
rem    this bat-file can write temporary files
rem    Do NOT end the directory-name with a backslash (\)

SET FTPTEMP=C:\TMP
REM ================================================
REM = NO NEED TO CHANGE ANYTHING BELOW THESE LINES =
REM ================================================
REM check settings of this .bat file
SET BATERROR=N
IF "%DEBUGBAT%" == "Y" (
     CALL :CheckBatSettings
)
IF %BATERROR% == Y GOTO Cheesyone


rem only for new files
IF %WD_REASON% == FILENEW GOTO FtpTheFile

Echo Only NEW files will be ftp-ed...

GOTO Done

:FtpTheFile
rem change to the directory of the new file
rem WD_FILE_D contains the directory where the new file
rem is located.
rem If the new file is C:\TEMP\File.ext this variable will contain C:\TEMP
cd "%WD_FILE_D%"

rem now build a response file containing the FTP commands
SET RESFI="%FTPTEMP%\%WD_FILE_B%.TMP"

ECHO verbose off              >  %RESFI%
ECHO open %FTPSERVER% >> %RESFI%
ECHO user %FTPUSER% %FTPPASS% >> %RESFI%
ECHO bin                      >> %RESFI%
ECHO cd %FTPDIR%              >> %RESFI%
ECHO put "%WD_FILE_N%"        >> %RESFI%
ECHO quit                     >> %RESFI%

rem ok, we created a file we want to be executed by ftp
rem start ftp
rem   -n means suppress autologin
rem   -s:c:\temp\ftp.in means take commands from that file
ftp -n -s:%RESFI%
del %RESFI%
rem Done!
GOTO Done


rem ==== CheckBatSettings
rem this subroutine is called if DEBUGBAT equals Y
rem it performs some simple checks to see if this .bat file
rem is properly setup
GOTO Cheesyone
:CheckBatSettings
IF NOT EXIST "%FTPTEMP%\." (
     SET BATERROR=Y
     "%WD_INSTDIR%\MBox.exe" "The variable FTPTEMP is not set correctly" -caption "Configuration problem" -icon ! -type ok
     GOTO :Eof
)

GOTO :Eof


Cheesyone

---------------------------------------
Where do i need the bat for connecting and put files to Secure FTP Server using WinSCP?
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: How can I send files to SFTP Server?
Reply #6 - Apr 13th, 2005 at 4:22pm
 
Well, I never used WinSCP, but I guess you would replace
Code:
 ftp -n -s:%RESFI% 


(near the bottom of your script) with
Code:
scp "%WD_FILE%" user@host:\mydir
 


user would be your userid, host your sftp hostname.

But, like I said.... I don't know.

Gert
Back to top
 

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
Raj
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 3
Re: How can I send files to SFTP Server?
Reply #7 - May 3rd, 2005 at 8:37pm
 
I use winscp, watchdirectory and waitdone to mirror 2 servers, I haven't looked at or changed the code in a while but it works thanks to the help of Gert, below is it take a look it might help. This is what I have watchdirectory fire. Also note the line that has SavedSession@YourServer.Com is a WinScp saved session with the password. Hope it helps.

if exist C:\WinSCPBatch\Folderinfo.txt goto :updatesent

echo option batch on >> "C:\WinSCPBatch\folderinfo.txt"
echo option confirm off >> "C:\WinSCPBatch\folderinfo.txt"

start /min C:\WinSCPBAtch\waitdone.bat

if exist C:\WinSCPBatch\sentinel\sentinel.txt goto :updatesent

echo option batch on >> "C:\WinSCPBatch\folderinfo.txt"
echo option confirm off >> "C:\WinSCPBatch\folderinfo.txt"

rem start /min C:\WinSCPBAtch\waitdone.bat

:updatesent
echo hello >> C:\WinSCPBAtch\Sentinel\sentinel.txt
rem is there already a synchronize command present in this file?
FINDSTR /L "put ""%WD_FILE%"" " "C:\WinSCPBatch\folderinfo.txt"
if %errorlevel% == 0 GOTO :AlreadyInFile

echo cd "/home/%WD_RELDIR%" >> "C:\WinSCPBatch\folderinfo.txt"
echo put "%WD_FILE%" >> "C:\WinSCPBatch\folderinfo.txt"


:AlreadyInFile




This is the waitdone.bat

:again
C:\WinSCPBAtch\nothingsChanged\nothingsChanged.exe 10 C:\WinSCPBAtch\Sentinel
if %errorlevel% == 1 goto nochanges
goto again
:nochanges
c:
cd \WinSCPBatch
rem  rename folderinfo so if new changes are detected, they will
rem  be written to a fresh folderinfo.txt
ren folderinfo.txt scriptfile.txt
echo exit >> scriptfile.txt
winscp3.exe SavedSession@YourServer.Com /console /script=c:\WinSCPBAtch\scriptfile.txt
del C:\WinSCPBatch\scriptfile.txt
if exist C:\WinSCPBatch\folderinfo.txt GOTO again
del C:\WinSCPBAtch\sentinel\sentinel.txt
exit


Back to top
 
 
IP Logged
 
Page Index Toggle Pages: 1