China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-10 23:05
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] How to modify specified content to achieve FTP upload of specified files View 2,466 Replies 6
Original Poster Posted 2008-12-07 08:13 ·  中国 广东 东莞 电信
新手上路
Credits 11
Posts 10
Joined 2008-12-02 02:05
17-year member
UID 132632
Gender Male
Status Offline
```batch
set route=%cd%
set ravel=
set /p ravel=Please enter the file to upload:
set "ravel=%ravel:"=%"

rem Modify ftp.txt to replace c:\1.txt with the obtained variable
for /f "delims=" %%a in ('type ftp.txt') do (
set "line=%%a"
setlocal enabledelayedexpansion
set "line=!line:c:\1.txt=!ravel!"
echo(!line!>>new_ftp.txt
endlocal
)
move /y new_ftp.txt ftp.txt>nul
```


Transferred from DOS Troubleshooting & Problem Discussion (Q&A Room)
Please post in the corresponding section in the future.
——Administrator


───────────────── Moderation Record ─────────────────
Performed by: HAT
Operation: Added search keywords in the post title; added code tags to the code
Description: The original title "How to modify specified content" was not conducive to forum search
Punishment: Deducted 2 points
Tip: It is recommended to read the following posts
{1415}The Wisdom of Asking Questions
{7326}Essential Guidelines for Forum Newcomers, Basic Behavior Norms for Everyone
{22703}Please Don't Be an Impatient Person
{32667}Those Who Can't Even Write a Clear Title, Wake Up!
{32825}This Section Severely Rectifies Poor-quality Posts
───────────────── Moderation Record ─────────────────


[ Last edited by HAT on 2008-12-9 at 09:40 ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
HAT -2 2008-12-09 09:40
Floor 2 Posted 2008-12-07 12:00 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
It is suggested to ask questions in the batch processing room next time
Floor 3 Posted 2008-12-09 00:49 ·  中国 广东 东莞 电信
新手上路
Credits 11
Posts 10
Joined 2008-12-02 02:05
17-year member
UID 132632
Gender Male
Status Offline
Floor 4 Posted 2008-12-09 10:32 ·  中国 广东 深圳 电信
初级用户
★★
游手好闲 + 无所事事 ..
Credits 194
Posts 167
Joined 2007-04-30 09:43
19-year member
UID 87022
Gender Male
Status Offline
Is this okay?

echo open 192.168.0.13>ftp.txt
echo 123>>ftp.txt
echo 123 >>ftp.txt
echo cd wwwroot>>ftp.txt
echo put c:\%你的变量%.txt>>ftp.txt
echo bye>>ftp.txt

ftp -s:ftp.txt


Note that I added an extra space after the password; if there's no space, it will get stuck there.

[ Last edited by exzzz on 2008-12-9 at 10:34 ]
Floor 5 Posted 2008-12-09 10:46 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
```
@echo off
set /p ravel=Please enter the file to upload:
set "ravel=%ravel:"=%"
>ftp.txt echo open 192.168.0.13
>>ftp.txt echo 123
>>ftp.txt echo 123
>>ftp.txt echo cd wwwroot
>>ftp.txt echo put "%ravel%"
>>ftp.txt echo bye
start ftp -v -i -s:"%ftpFile%"
```
Floor 6 Posted 2008-12-09 11:52 ·  中国 广东 深圳 电信
初级用户
★★
游手好闲 + 无所事事 ..
Credits 194
Posts 167
Joined 2007-04-30 09:43
19-year member
UID 87022
Gender Male
Status Offline
set "ravel=%ravel:"=%"

Does the HAT moderator mean that this sentence refers to using the set command to remove the spaces in the variable ravel?
I saw in set /? that there is such a passage:

Environment variable substitution has been enhanced as follows:

%PATH:str1=str2%

This will expand the PATH environment variable, replacing each "str1" in the expanded result with "str2"
To effectively remove all "str1" from the expanded result, "str2" can be empty.

Then what is the effect of "str2 can be empty."? I tested it, and the variable doesn't seem to change?
Floor 7 Posted 2008-12-09 12:31 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
The landlord means to delete the double quotes that the user may input to avoid causing errors in the subsequent commands.
Forum Jump: