One cmd line with all the code inline

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
hacxx
Posts: 26
Joined: 09 Apr 2015 13:18

One cmd line with all the code inline

#1 Post by hacxx » 08 Aug 2018 12:08

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

aGerman
Expert
Posts: 3706
Joined: 22 Jan 2010 18:01
Location: Germany

Re: One cmd line with all the code inline

#2 Post by aGerman » 08 Aug 2018 15:33

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

ShadowThief
Expert
Posts: 909
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: One cmd line with all the code inline

#3 Post by ShadowThief » 08 Aug 2018 19:16

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.

hacxx
Posts: 26
Joined: 09 Apr 2015 13:18

Re: One cmd line with all the code inline

#4 Post by hacxx » 09 Aug 2018 02:24

aGerman wrote:
08 Aug 2018 15:33
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
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

hacxx
Posts: 26
Joined: 09 Apr 2015 13:18

Re: One cmd line with all the code inline

#5 Post by hacxx » 09 Aug 2018 02:25

ShadowThief wrote:
08 Aug 2018 19:16
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.
I have retried the & and it did work but it didn't execute (see the post above)

Squashman
Expert
Posts: 4111
Joined: 23 Dec 2011 13:59

Re: One cmd line with all the code inline

#6 Post by Squashman » 09 Aug 2018 06:22

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

aGerman
Expert
Posts: 3706
Joined: 22 Jan 2010 18:01
Location: Germany

Re: One cmd line with all the code inline

#7 Post by aGerman » 09 Aug 2018 07:27

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

hacxx
Posts: 26
Joined: 09 Apr 2015 13:18

Re: One cmd line with all the code inline

#8 Post by hacxx » 09 Aug 2018 13:52

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

Image

EDIT: 2 hours posting project

Post Reply