exec echo /dev/tcp

Post Reply
aitchon
Posts: 106
Joined: Mon Jan 22, 2007 10:30 am

exec echo /dev/tcp

Post 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?
User avatar
Kai
Site Admin
Posts: 1263
Joined: Tue Apr 25, 2000 1:27 pm

exec echo /dev/tcp

Post 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.
User avatar
John
Site Admin
Posts: 2580
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

exec echo /dev/tcp

Post 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?
John Turnbull
Thunderstone Software
aitchon
Posts: 106
Joined: Mon Jan 22, 2007 10:30 am

exec echo /dev/tcp

Post 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 -->
User avatar
Kai
Site Admin
Posts: 1263
Joined: Tue Apr 25, 2000 1:27 pm

exec echo /dev/tcp

Post 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?
User avatar
Kai
Site Admin
Posts: 1263
Joined: Tue Apr 25, 2000 1:27 pm

exec echo /dev/tcp

Post 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>
aitchon
Posts: 106
Joined: Mon Jan 22, 2007 10:30 am

exec echo /dev/tcp

Post by aitchon »

Thanks to both of you. That seems to work fine.
aitchon
Posts: 106
Joined: Mon Jan 22, 2007 10:30 am

exec echo /dev/tcp

Post 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?
User avatar
Kai
Site Admin
Posts: 1263
Joined: Tue Apr 25, 2000 1:27 pm

exec echo /dev/tcp

Post 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 ?
User avatar
mark
Site Admin
Posts: 5495
Joined: Tue Apr 25, 2000 6:56 pm

exec echo /dev/tcp

Post 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.
Post Reply