Old fashioned S010 ([info]0x1392) wrote,
@ 2009-07-01 11:19:00
Previous Entry  Add to memories!  Tell a Friend  Next Entry
Entry tags:fun, i did it for teh lulz, programming, shell, sockets, software

Mou KaKaLLIku <3

tnamed

Aka trivial name daemon. I can never remember what IP addresses comps on my LAN have, an obvious solution is to add ip->hostname mappings to /etc/hosts file. But wtf, the computer should make my life easier not add more problems. And then you'll have to use static IP addresses or tell DHCP server to always assign the same IPs for certain MACs.

When you run tnamed, it:

  1. acquires the list of IP address that the machine has
  2. for each of the IP addresses, it broadcasts to the subnet 255.255.255.0 a message telling that it's located at that IP address :D Makes no sense, right? Example: a machine has a hostname of "slowpoke" and IP addresses 192.168.0.1, 89.191.97.180, then it will broadcast a message "slowpoke@192.168.0.1" to every host in 192.168.0 and "slowpoke@89.191.97.180" to every host in 89.191.97
  3. It then broadcasts a request for other hosts to announce themselves to the subnets the computer is connected to
  4. Then it goes into an endless loop waiting for incoming messages; when it gets a request to announce self, it does (1); when it gets other host's announcment, it adds an entry to /etc/hosts file
    The hosts file may look something like this after tnamed:
    127.0.0.1 slowpoke # Following entries added by tnamed 192.168.0.11 x2 192.168.0.10 d400
  5. When you kill tnamed, it restores the original /etc/hosts file

tnamed is intended as a zero-configuration daemon, it doesn't need any conf files or command line options. To use it, simply run it from root, on all the participating machines.
Say, you have three machines on you LAN, "host1", "host2" and "host3". Run tnamed on each of the comps. And then, being logged in on one of these comps, you can address the other two by names, liek ping host2

http://s010.lv/files/tnamed.c -- current version is somewhere like 0.5, the code is a little rough and I have one other thing I want to add for great justice =)

On BSD, compile like cc -DBSD -o tnamed tnamed.c, on linux, simply cc -o tnamed tnamed.c

lstree

s@slowpoke:0:~/src/svn/my/utils$ ./lstree -h List files and directories in a fancy way. usage: lstree [-d] [-m ] [-t ] [path1 path2...] -z -- reverse sort order -d -- show directories first -m -- max depth (inf. by default) -t -- tabulation string (four spaces by default) -F -- display a char denoting file's type -g -- draw a compact pseudo-graphics tree (-d implied) -G -- draw a pseudo-graphics tree (-d implied)

Example output:
s@slowpoke:0:~/src/svn/my/utils$ ./lstree -g -F op op/ `-.svn/ | `-prop-base/ | `-props/ | `-text-base/ | | `-INSTALL.svn-base | | `-LICENSE.svn-base | | `-Makefile.in.svn-base | | `-README.svn-base | | `-configure.ac.svn-base | | `-op.conf_example.svn-base | `-tmp/ | | `-prop-base/ | | `-props/ | | `-text-base/ | `-entries | `-format `-src/ ...

http://s010.lv/files/lstree.c

shell2

Continuation of http://0x1392.livejournal.com/138681.html.

This is now a real command interpreter in that it actually parses the line entered, builds a parse tree and then executes the tree. Supported operators are

&&
AND operator, same as in common shells
||
OR operator, same as in common shells
;
execute mutliple commands in one line
&
execute in background
><
suppress any kind of output (stdout and stderr); liek stfu! ><
>
redirect stdout to file
^>
redirect stderr to file
>>
append stdout to file
<
redirect stdin from file
!
NOT operator, for use with AND and OR

Example run:
s:/home/s/src/svn/my/misc/shell$ ls asd && ls / AND EVAL ls asd EVAL ls / trav_tree(): pid=17910 trav_tree(): pid=17910 ls: asd: No such file or directory s:/home/s/src/svn/my/misc/shell$ ls asd || ls / OR EVAL ls asd EVAL ls / trav_tree(): pid=17910 trav_tree(): pid=17910 ls: asd: No such file or directory trav_tree(): pid=17910 altroot bin boot bsd bsd.rd dev etc home mnt root sbin stand sys tmp usr var s:/home/s/src/svn/my/misc/shell$

http://s010.lv/files/shell.c, compiles like cc -lreadline -lcurse -o shell shell.c

clock.sh

Sort of a screen saver for console. Displays a clock which moves around the screen and bumps off the walls. Most interesting feature -- written in shell.

Screenshot of an xterm window:
Free Image Hosting at www.ImageShack.us

http://s010.lv/files/clock.sh




(7 comments) - (Post a new comment)


[info]goodsoft
2009-07-01 09:44 am UTC (link)
Ты тоже придерживаешься мнения, что заголовочный комментарий к программе должен на 5% состоять из копирайта, на 95% из копипасты лицензии и на 0% из описания того, что делает программа?

(Reply to this) (Thread)

+1
[info]__spawn__
2009-07-01 09:49 am UTC (link)
)))))))))))))))))))))))))))))))

(Reply to this) (Parent)


[info]0x1392
2009-07-06 08:24 am UTC (link)
Гы, да, надо бы добавить

(Reply to this) (Parent)


[info]__spawn__
2009-07-01 09:49 am UTC (link)
Ты там не домашки по ОС делаешь? )
Блин, помню ты меня реально выручил тогда с ними. =)

(Reply to this) (Thread)


[info]0x1392
2009-07-06 08:26 am UTC (link)
Единственная которая хоть как-то связана с инстом -- клок.сх. Там было задание, да, по ОС, я даже не знаю точно что там было задано, типа вывести часы посреди экрана, ну я такую вот мулю сделал.
Я удивлен что ты помнишь что это я был =)

(Reply to this) (Parent)


[info]sweater_judah
2009-07-01 10:26 am UTC (link)
cупер.
программировать для себя - это так круто -_-

(Reply to this) (Thread)


[info]0x1392
2009-07-06 08:26 am UTC (link)
true

(Reply to this) (Parent)


(7 comments) - (Post a new comment)

Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…