Page 1 of 1

exec echo /dev/tcp

Posted: Thu Dec 03, 2015 12:16 pm
by aitchon
I have a Vortex script that uses exec to echo data to /dev/tcp which sends data to another server by tcp/ip. It seems that using the command line for bash has a limitation of the number of characters. Is there any way around this in Vortex, or would I have to write a user function to do this?

exec echo /dev/tcp

Posted: Thu Dec 03, 2015 12:44 pm
by Kai
Can you use <write> to write directly to /dev/tcp, instead of <exec>'ing echo or bash? Then there is no command-line involved.

exec echo /dev/tcp

Posted: Thu Dec 03, 2015 12:45 pm
by John
Depending on the exact command you are using anything between the <exec> and </exec> will be the standard input to the program, so that may let you send as much as you want rather than putting it on the command line?

exec echo /dev/tcp

Posted: Thu Dec 03, 2015 1:59 pm
by aitchon
Kai - I tried write, but I got this output:

<!-- 002 testwrite:24: Cannot open /dev/tcp/192.168.0.1/49159: No such file or directory in the function dowrite -->

exec echo /dev/tcp

Posted: Thu Dec 03, 2015 2:47 pm
by Kai
Ok that's probably a consequence of some interaction between the fact that the path is a device and how <write> opens files. What version of Texis is this, and what is your <exec> echo command line?

exec echo /dev/tcp

Posted: Thu Dec 03, 2015 3:14 pm
by Kai
It looks like /dev/tcp is a bash-ism, i.e. it does not exist in the real filesystem (as a device or not), but only for file paths that are evaluated directly by bash -- e.g. file redirection on a bash command line. That's why <write> didn't work -- it looks at the filesystem.

John's answer seems like it should still work though: use bash to open the /dev/tcp socket, but use <exec>'s stdin to send the data:

<exec "bash" "-c" "cat >/dev/tcp/192.168.0.1/49159">
<fmt "send all the data here\n">
</exec>

exec echo /dev/tcp

Posted: Thu Dec 03, 2015 3:36 pm
by aitchon
Thanks to both of you. That seems to work fine.

exec echo /dev/tcp

Posted: Thu Dec 03, 2015 4:48 pm
by aitchon
Actually, it still looks like there's still a limitation on the amount of data being sent. I can send under 130k bytes of data with success. Anything over that doesn't work. I don't get an error return from exec. Do you think it's a limitation when sending data to /dev/tcp or is exec still using the command line?

exec echo /dev/tcp

Posted: Thu Dec 03, 2015 5:48 pm
by Kai
What happens when you send over 130k: error? data past that lost? something else?

Does >130k data work outside of Vortex, e.g. `cat hugeFile.txt >/dev/tcp/whatever' from a shell prompt ?

exec echo /dev/tcp

Posted: Thu Dec 03, 2015 5:55 pm
by mark
To answer your question about the command line. Given:

<exec "bash" "-c" "cat >/dev/tcp/192.168.0.1/49159">
<fmt "send all the data here\n">
</exec>

"-c" "cat >/dev/tcp/192.168.0.1/49159" is the only thing on the command line.
<fmt "send all the data here\n"> is fed into cat's stdin.