Hi,
I'm trying to build a batch file using just one line for FTP access. For this i'm using "cmd /c" as a starter and then the commands are in front of it. I have tried diferent ways but i can't seem to find a way to make it work. If i try one long string i can't execute it. If i use the ">" to save to a file the code needs to be formated with a break line separating each command i have tried \n, &, &&, echo. between others and nothing. Any tips?
I read here in the forum about EOL code but i couldn't figure it out!
Thanks
One cmd line with all the code inline
Moderator: DosItHelp
Re: One cmd line with all the code inline
Since nobody replied yet I suspect nobody really understood what you're trying to do. Neither do I. You should post the lines of code that you tried. Maybe it'll get more clear then.
Steffen
Steffen
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: One cmd line with all the code inline
Yeah, I'm really unclear on why you're trying to do this outside of it either being homework or you just want to know if it's possible.
Also, chaining FTP commands has nothing to do with batch and everything to do with FTP itself. That said, if & didn't work for you, nothing will, since the "correct" way to do an FTP one-liner is to make a temporary file with each command on a separate line.
Also, chaining FTP commands has nothing to do with batch and everything to do with FTP itself. That said, if & didn't work for you, nothing will, since the "correct" way to do an FTP one-liner is to make a temporary file with each command on a separate line.
Re: One cmd line with all the code inline
I'm trying to create a file and then execute it
Code: Select all
cmd /c echo ftp.exe>text.bat & echo open 127.0.0.1>>text.bat & echo username>>text.bat & echo password>>text.bat text.bat
Re: One cmd line with all the code inline
I have retried the & and it did work but it didn't execute (see the post above)ShadowThief wrote: ↑08 Aug 2018 19:16Yeah, I'm really unclear on why you're trying to do this outside of it either being homework or you just want to know if it's possible.
Also, chaining FTP commands has nothing to do with batch and everything to do with FTP itself. That said, if & didn't work for you, nothing will, since the "correct" way to do an FTP one-liner is to make a temporary file with each command on a separate line.
Re: One cmd line with all the code inline
I think you would need & Text.bat at the end to execute the bat file. But why? Just echo the ftp commands to a script file and the execute ftp.exe with the script file.
I think you could also chain the ftp commands inside parentheses and pipe to ftp.
(Echo open server & echo username & echo password & echo put file.txt)|ftp.exe
I think you could also chain the ftp commands inside parentheses and pipe to ftp.
(Echo open server & echo username & echo password & echo put file.txt)|ftp.exe
Re: One cmd line with all the code inline
Don't mix up Batch and FTP. You can pass an FTP script to ftp.exe but you cannot have Batch code in an FTP script and then assume that it will automatically work. Those are two languages even if the commands are pretty similar.
There are possibilities to have both in one script:
https://www.dostips.com/DtTipsFtpBatchScript.php
But I'd prefer to write the FTP script to an extra file.
Steffen
There are possibilities to have both in one script:
https://www.dostips.com/DtTipsFtpBatchScript.php
But I'd prefer to write the FTP script to an extra file.
Steffen
Re: One cmd line with all the code inline
So nothing useful
Download
http://www.mediafire.com/file/b923yn0pc ... rator.html
Virustotal
https://www.virustotal.com/#/file/4a36e ... /detection
Download 2 (Works only with Internet Explorer >|11)
http://www.mediafire.com/file/djvca2dtm ... 86923.html
EDIT: 2 hours posting project
Download
http://www.mediafire.com/file/b923yn0pc ... rator.html
Virustotal
https://www.virustotal.com/#/file/4a36e ... /detection
Download 2 (Works only with Internet Explorer >|11)
http://www.mediafire.com/file/djvca2dtm ... 86923.html
EDIT: 2 hours posting project