Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Awk and netcat... anything else that can be used to send output to a browser?

Featured Replies

Suggestions sought .... what else small and scriptable, other than awk and netcat, can you use to listen to a tcp socket and send text to a browser?

Suggestions sought .... what else small and scriptable, other than awk and netcat, can you use to listen to a tcp socket and send text to a browser?

Would you believe the shell? 

 

Here is an interesting web-page: http://blogmag.net/blog/read/49/Network_programing_with_bash

 

Joe L.

 

Check out this greatly simplified version of "wget" ( i don't think it works on binary files, but you can see the syntax to connect to a tcp socket.)

[pre]

#!/bin/bash

#http://blogmag.net/blog/read/49/Network_programing_with_bash

#

PATH=${2-/}

 

exec 6<>/dev/tcp/$1/80

 

echo -e "GET ${PATH} HTTP/1.1" >&6

echo -e "Host: $1\nConnection: close\n" >&6

echo "Reading: http://${1}${PATH}" >&2

 

#read and discard the header

while read <&6

do

    LINE=${REPLY//$'\r'/}

    if [ -z "$LINE" ]; then

        break

    fi

done

 

#read the page

while read <&6

do

    echo -n $REPLY >&1

done

# close the file descriptor

exec 6<&-

exec 6>&-

[/pre]

  • Author

Ahh yes... the line:

 

exec 6<>/dev/tcp/$1/80

 

is what I needed.  Thanks!

 

Now I just need to figure out how to either 1) disable buffering, 2) set a small buffer, or 3) flush the buffer.

  • Author

Spoke too soon... you can't listen on the bash tcp pseudo devices... >:(

Not sure what you are trying to do, however it is possible to have a bash shell spawned from inetd which will connect stdin and stdout to the network connection.

  • Author

I know, but this is part of a utility that needs to be run and stop... I can't leave an open port hanging out like that.

I know, but this is part of a utility that needs to be run and stop... I can't leave an open port hanging out like that.

 

Undertstood.

You might want to think about "awk" :)

  • Author

Awk and netcat were in the OP.... but both buffer output, and that won't work for this project

 

Believe me, I tried awk for hours, but the damn buffering was killing me.

 

 

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.