Bash Socket Programming

Standard

From: http://hacktux.com/bash/socket


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

tldp.org: Advanced Bash-Scripting Guide – Chapter 29
thesmithfam.org: Bash socket programming with /dev/tcp


723 total views, no views today

PHP: _POST – Manual

Standard

PHP: _POST – Manual.

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

425 total views, no views today

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

Standard

From: http://bytes.com/topic/javascript/answers/743778-please-help-me-updating-dom-element-javascript-contents

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’;
try{
el.appendChild(document.createTextNode(s));
}
catch(er){
el.text= s;
}
return document.getElementsByTagName(‘head’)[0].appendChild(el);
}

414 total views, 1 views today