Giving more commands when a program has been executed

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
q-bertsuit
Posts: 2
Joined: 16 Feb 2012 02:15

Giving more commands when a program has been executed

#1 Post by q-bertsuit » 16 Feb 2012 02:21

Hi,

I'm completely new to writing batch scripts. I'd like my script to run netcat and then send a few commands, but when I run it, the script stops and waits for netcat to exit.

Is there a way to write commands when the netcat promt comes up? This is what I have done so far:

:: WP.bat
:: Runs WordPerfect
::
::@ECHO OFF

C:
nc -u 192.168.xxx.xx 60000
set_transport_type:tcp
^C

After the " nc -u 192.168.xxx.xx 60000 " command netcat prompts and is ready for commands, but the "set_transport_type:tcp" is never run.

Thank you for your time

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Giving more commands when a program has been executed

#2 Post by foxidrive » 16 Feb 2012 02:27

You want these command executed inside netcat, not the command line, right?

That's not a batch file issue but a script issue for netcat, if netcat accepts script files.

q-bertsuit
Posts: 2
Joined: 16 Feb 2012 02:15

Re: Giving more commands when a program has been executed

#3 Post by q-bertsuit » 16 Feb 2012 02:31

Thank you your answer.

Yes, I would like it to execute these commands inside netcat, but it still runs in the cmd window?

So there is no easy way around this?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Giving more commands when a program has been executed

#4 Post by foxidrive » 16 Feb 2012 05:40

Look at the help for netcat to see how to use a script file or provide a URL to the version you are using, so one of us can have a look.

Aacini
Expert
Posts: 1930
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Giving more commands when a program has been executed

#5 Post by Aacini » 18 Feb 2012 22:01

You may try this:

Code: Select all

C:
(
echo set_transport_type:tcp
echo ^C
) | nc -u 192.168.xxx.xx 60000

Post Reply