Bash Socket Programming



You can connect to a socket using Bash by using exec and redirecting to and from the pseudo-path /dev/tcp/<hostname>/<port> or /dev/udp/<hostname>/<port>. For instance, to connect to your localhost SSH port using TCP:

Then, use cat and echo to read or write to the socket. Here is an example read:

Notice that there is no such file as /dev/tcp or /dev/udp. Bash interprets the pseudo-path.

As another example, maybe you want to download a webpage:

Finally, let’s say you wanted to connect to an IRC server. Here is an example:

Sources Advanced Bash-Scripting Guide – Chapter 29 Bash socket programming with /dev/tcp

604 total views, no views today

PHP: _POST – Manual


PHP: _POST – Manual.

james dot ellis at gmail dot com 15-Dec-2008 01:38

347 total views, no views today

How to add a textnode to script and allow a fallback.



How to add code with createTextNode using “appendChild” to a “<script>”.

Fact is, as of right now- 2010/05/17 with the Internet Explorer 8 and below you cannot use the “document.createTextNode()” and append it to a “document.createElement(‘script’)”.

So the code below will allow you to by default use the normal method and fallback to IE’s method.

For IE you must use the .TEXT.

Eg: document.createElement(‘script’).text=”TEST CODE”;

document.newScript= function(s){
var el= document.createElement(‘script’);
el.type= ‘text/javascript’;
el.text= s;
return document.getElementsByTagName(‘head’)[0].appendChild(el);

345 total views, no views today