Merci pour le code. mais je vois pas trop comment m'en servir...
Ce code est le .bat? Que met on dans le .txt? (j'imagine qu'il est nommé FTPScript.txt)
Version imprimable
Je te l'ai refait, il faut que tu utilise la commande suivante pour le download:
<scriptname> /dir="camping" /get="toto.txt" /user="sinutech" /pwd="<password>" /url=ftp.***.ovh.net
il faut que tu utilise la commande suivante pour l'upload:
<scriptname> /dir="camping" /put="%cd%\toto.txt" /user="sinutech" /pwd="<password>" /url=ftp.***.ovh.net
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113 @echo off setlocal set /a "ExitCode=0" set /a "UpAndDown=-1" set "MountPoint=" set "LoadMode=binary" :ParseArgs if "%~1"=="" goto Init if /i "%~1"=="/get" ( set /a "UpAndDown=0" set "WorkingFile=%~2" if "%~x2"==".txt" set "LoadMode=ascii" shift /1 shift /1 goto ParseArgs ) if /i "%~1"=="/put" ( set /a "UpAndDown=1" set "WorkingFile=%~2" if "%~x2"==".txt" set "LoadMode=ascii" shift /1 shift /1 goto ParseArgs ) if /i "%~1"=="/dir" ( set "MountPoint=%~2" shift /1 shift /1 goto ParseArgs ) if /i "%~1"=="/user" ( set "User=%~2" shift /1 shift /1 goto ParseArgs ) if /i "%~1"=="/pwd" ( set "Password=%~2" shift /1 shift /1 goto ParseArgs ) if /i "%~1"=="/url" ( set "ServerURL=%~2" shift /1 shift /1 goto ParseArgs ) :BadSyntax echo %~1 %~2 for /f "delims=" %%a in ('net helpmsg 87') do ( >&2 echo [ %~1 ] %%a ) if not "%~0"==":BadSyntax" endlocal exit /b 87 :Init if not defined WorkingFile goto UnknownError if not exist "%WorkingFile%" goto UnknownError if not defined User goto UnknownError if not defined Password goto UnknownError if not defined ServerURL goto UnknownError set "FTPScriptPath=%Date:/=%%Time::=%" set "FTPScriptPath=%FTPScriptPath:,=%" if %UpAndDown% neq -1 goto Exec :UnknownError if %UpAndDown% equ -1 ( call :BadSyntax "/get /put" ) else if not defined WorkingFile ( call :BadSyntax "/dir" ) else if not exist "%WorkingFile%" ( call :BadSyntax "%WorkingFile%" ) else if not defined User ( call :BadSyntax "/user" ) else if not defined Password ( call :BadSyntax "/pwd" ) else if not defined ServerURL ( call :BadSyntax "/url" ) echo. endlocal exit /b 87 :Exec ::Creation du script FTP call :WrhiteFTPScript 1>>%FTPScriptPath% ::Transaction avec le serveur et initialisation du code d'erreur ftp -v -s:"%FTPScriptPath%" %ServerURL% set /a "ExitCode=%ErrorLevel%" ::Suppression du script FTP del /Q "%FTPScriptPath%" goto End :WrhiteFTPScript echo %User% echo %Password% echo %LoadMode% if defined MountPoint echo cd %MountPoint% if "%UpAndDown%"=="0" ( echo get %WorkingFile% ) else ( echo put %WorkingFile% ) echo bye goto :eof :End if not "%~0"==":Help" endlocal exit /b 0
Et tu n'a pas besoin d'un script ftp le batch le crée tout seul
Merci pour la réponse. Mais j'ai commande incorrect qui s'affiche dans le boîte de dialogue...
Script.bat:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109 @echo off setlocal set /a "ExitCode=0" set /a "UpAndDown=-1" set "MountPoint=" set "LoadMode=binary" :ParseArgs if "%~1"=="" goto Init if /i "%~1"=="/get" ( set /a "UpAndDown=0" set "WorkingFile=%~2" if "%~x2"==".txt" set "LoadMode=ascii" shift /1 shift /1 goto ParseArgs ) if /i "%~1"=="/put" ( set /a "UpAndDown=1" set "WorkingFile=%~2" if "%~x2"==".txt" set "LoadMode=ascii" shift /1 shift /1 goto ParseArgs ) if /i "%~1"=="/dir" ( set "MountPoint=%~2" shift /1 shift /1 goto ParseArgs ) if /i "%~1"=="/user" ( set "User=%~2" shift /1 shift /1 goto ParseArgs ) if /i "%~1"=="/pwd" ( set "Password=%~2" shift /1 shift /1 goto ParseArgs ) if /i "%~1"=="/url" ( set "ServerURL=%~2" shift /1 shift /1 goto ParseArgs ) :BadSyntax echo %~1 %~2 for /f "delims=" %%a in ('net helpmsg 87') do ( >&2 echo [ %~1 ] %%a ) if not "%~0"==":BadSyntax" endlocal exit /b 87 :Init if not defined WorkingFile goto UnknownError if not exist "%WorkingFile%" goto UnknownError if not defined User goto UnknownError if not defined Password goto UnknownError if not defined ServerURL goto UnknownError set "FTPScriptPath=%Date:/=%%Time::=%" set "FTPScriptPath=%FTPScriptPath:,=%" if %UpAndDown% neq -1 goto Exec :UnknownError if %UpAndDown% equ -1 ( call :BadSyntax "/get /put" ) else if not defined WorkingFile ( call :BadSyntax "/dir" ) else if not exist "%WorkingFile%" ( call :BadSyntax "%WorkingFile%" ) else if not defined User ( call :BadSyntax "/user" ) else if not defined Password ( call :BadSyntax "/pwd" ) else if not defined ServerURL ( call :BadSyntax "/url" ) echo. endlocal exit /b 87 :Exec ::Creation du script FTP call :WrhiteFTPScript 1>>%FTPScriptPath% ::Transaction avec le serveur et initialisation du code d'erreur ftp -v -s:"%FTPScriptPath%" %ServerURL% set /a "ExitCode=%ErrorLevel%" ::Suppression du script FTP del /Q "%FTPScriptPath%" goto End :WrhiteFTPScript echo %User% echo %Password% echo %LoadMode% if defined MountPoint echo cd %MountPoint% if "%UpAndDown%"=="0" ( echo get %WorkingFile% ) else ( echo put %WorkingFile% ) echo test pause
scriptname.txt:
Code:/dir="camping" /put="C:\Users\m.bignard\Desktop\etude de script\Script 4\toto.txt" /user="**" /pwd="<**>" /url=ftp.**.ovh.net
Voilà ce que j'ai en pur et dur.
En fait c'est le script batch qu'il faut appeler avec la commande que je t'ai donné. Le script va créer le script FTP tout seul pas besoin de lui fournir.
et dans la commande <scriptname> est le nom que tu donne au script batch, par exemple script.bat