Copy file to remote server with username and pasword?
Moderator: DosItHelp
Copy file to remote server with username and pasword?
Instead to copyfiles in my local directory(pushd "c:\LASTNO\FTP\prenos\") I want to put them on server:
Here is server details:
set dest_server_name=192.xxx.xx.xx
set dest_username=lalala
set dest_password=123456
set dest_directory=/spark_data/RangerData/
Please write me in my code below how to do that?
----------------------------------------
Code:
@echo off
pushd "c:\LASTNO\FTP\prenos\"
set "db=file_database_DO_NOT_DELETE.txt"
if not exist "%db%" type nul>"%db%"
del list.ftp 2>nul
del list2.ftp 2>nul
del filelist.txt 2>nul
del filelist2.txt 2>nul
set server_name=v-sss-xxx
set username=racauser
set password=racapass
set remote_directory=raca/OTHERS/out
set filespec=GL_*.txt
for /f "delims=" %%a in ("%filespec%") do set filetype=%%~xa
echo ---------------------------------------------------------------------------
echo %date% %time% Begin Transfer
(
echo open %server_name%
echo %username%
echo %password%
echo cd %remote_directory%
echo ls %filespec%
echo quit
)>list.ftp
FTP -s:list.ftp >filelist.txt
for /f "delims=" %%a in (
'type "filelist.txt"^|find /i "%filetype%"^|find /i /v "ftp>"'
) do cmd /c >> filelist2.txt echo %%a
move /y filelist2.txt filelist.txt >nul
for /f "delims=" %%a in ('type "filelist.txt"') do (
find /i "%%a"<"%db%" >nul || >>filelist2.txt echo %%a
)
(
echo open %server_name%
echo %username%
echo %password%
echo binary
echo cd %remote_directory%
)>list2.ftp
for /f "delims=" %%a in ('type "filelist2.txt"') do (
>>list2.ftp echo mget %%a
>>list2.ftp echo y
>>"%db%" echo %%a
)
echo quit>>list2.ftp
FTP -s:list2.ftp
del list.ftp 2>nul
del list2.ftp 2>nul
del filelist.txt 2>nul
del filelist2.txt 2>nul
echo %date% %time% Done FTP Transfer
echo.
echo.
popd
Here is server details:
set dest_server_name=192.xxx.xx.xx
set dest_username=lalala
set dest_password=123456
set dest_directory=/spark_data/RangerData/
Please write me in my code below how to do that?
----------------------------------------
Code:
@echo off
pushd "c:\LASTNO\FTP\prenos\"
set "db=file_database_DO_NOT_DELETE.txt"
if not exist "%db%" type nul>"%db%"
del list.ftp 2>nul
del list2.ftp 2>nul
del filelist.txt 2>nul
del filelist2.txt 2>nul
set server_name=v-sss-xxx
set username=racauser
set password=racapass
set remote_directory=raca/OTHERS/out
set filespec=GL_*.txt
for /f "delims=" %%a in ("%filespec%") do set filetype=%%~xa
echo ---------------------------------------------------------------------------
echo %date% %time% Begin Transfer
(
echo open %server_name%
echo %username%
echo %password%
echo cd %remote_directory%
echo ls %filespec%
echo quit
)>list.ftp
FTP -s:list.ftp >filelist.txt
for /f "delims=" %%a in (
'type "filelist.txt"^|find /i "%filetype%"^|find /i /v "ftp>"'
) do cmd /c >> filelist2.txt echo %%a
move /y filelist2.txt filelist.txt >nul
for /f "delims=" %%a in ('type "filelist.txt"') do (
find /i "%%a"<"%db%" >nul || >>filelist2.txt echo %%a
)
(
echo open %server_name%
echo %username%
echo %password%
echo binary
echo cd %remote_directory%
)>list2.ftp
for /f "delims=" %%a in ('type "filelist2.txt"') do (
>>list2.ftp echo mget %%a
>>list2.ftp echo y
>>"%db%" echo %%a
)
echo quit>>list2.ftp
FTP -s:list2.ftp
del list.ftp 2>nul
del list2.ftp 2>nul
del filelist.txt 2>nul
del filelist2.txt 2>nul
echo %date% %time% Done FTP Transfer
echo.
echo.
popd
Re: Copy file to remote server with username and pasword?
I don't understand much about FTP but you can download the files then re-upload to the new one then delete files from your pc.
I don't know if the ftp can handle file transfer between servers
I don't know if the ftp can handle file transfer between servers
Re: Copy file to remote server with username and pasword?
Try this: replace this:
with this:
and replace the last line
popd
with this
net use z: /delete
Code: Select all
@echo off
pushd "c:\LASTNO\FTP\prenos\"
with this:
Code: Select all
@echo off
NET USE Z: \\192.168.1.1\spark_data\RangerData 123456 /USER:lalala
cd /d z:\
and replace the last line
popd
with this
net use z: /delete
Re: Copy file to remote server with username and pasword?
With net use I cannot login to server. I receive error: The network connection could not be found.
I CAN login use this:
ftp://username:passwords@192.168.1.1/
and 192.168.1.1 is Windows Server.
I CAN login use this:
ftp://username:passwords@192.168.1.1/
and 192.168.1.1 is Windows Server.
Re: Copy file to remote server with username and pasword?
izy wrote:With net use I cannot login to server. I receive error: The network connection could not be found.
Is the server online? The error message would seem to indicate that the IP address you used is not the right one.
That is of no use, unless you want to FTP everything to another FTP server.
An FTP server cannot keep a database of all the files transferred that is in the batch file.
Re: Copy file to remote server with username and pasword?
I just want to copy files instead to the local disk, copy files to another windows server. Server is online, but i put fake IP 192.168.1.1 because of security.
Re: Copy file to remote server with username and pasword?
I don't know what IP you put in but your error message shows that there is no server there.
Type this and tell me what happens. Use the correct IP address - and 192.168.x.x is not a security risk as it is behind a router.
net use z: \\192.168.1.1\spark_data\RangerData
Type this and tell me what happens. Use the correct IP address - and 192.168.x.x is not a security risk as it is behind a router.
net use z: \\192.168.1.1\spark_data\RangerData
Re: Copy file to remote server with username and pasword?
I receive error:
System error 53 has occurred.
The network path was not found.
The system cannot find the drive specified.
I try with this:
net use z: \\192.168.1.1\spark_data\RangerData
cd /d z:\
...
net use z: /delete
System error 53 has occurred.
The network path was not found.
The system cannot find the drive specified.
I try with this:
net use z: \\192.168.1.1\spark_data\RangerData
cd /d z:\
...
net use z: /delete
Re: Copy file to remote server with username and pasword?
http://answers.yahoo.com/question/index ... 115AA2Z370
This is not a batch file issue, izy, you will have to see your admin.
This is not a batch file issue, izy, you will have to see your admin.
Re: Copy file to remote server with username and pasword?
But can I use "net use -> cd /d z:\" if is it on other site windows server?
Re: Copy file to remote server with username and pasword?
NET USE can map a server to a local drive letter.
Then if it is mapped to z: you can use
cd /d z:\
Then if it is mapped to z: you can use
cd /d z:\
Re: Copy file to remote server with username and pasword?
But what if I couldn't "create" mapped disk like z: ?
Re: Copy file to remote server with username and pasword?
If you can't access the server then you cannot transfer files to it.
We can't tell what you have done and can only judge on the error reports that you tell us.
For some reason you can't log into the server - maybe your Admin have locked it down.
We can't tell what you have done and can only judge on the error reports that you tell us.
For some reason you can't log into the server - maybe your Admin have locked it down.
Re: Copy file to remote server with username and pasword?
Is it any other way instead of net use, like pushd to copy files to remote server?
Re: Copy file to remote server with username and pasword?
You can use pushd with a UNC path too, but as far as I know not with user and password.