...making Linux just a little more fun!
[Original question published as LG 122] help wanted #1]
[Evan] -
Modern AOL software for Microsoft Windows uses standard protocols (PPP, PPPoE) to establish link-layer connectivity. It then establishes a TCPIP connection to authenticate the user. This protocol is proprietary. Before authentication, a user's network traffic cannot reach the internet.To use AOL's ISP service on Linux, one must reverse engineer the authentication protocol. I am not certain anyone has done that.
[Francis] -
Hi there,
If I understand things correctly, the intention is that
client --> s1.example.com:80 --> received by apache --> content generated by apache --> content returned to client by apache
client --> s2.example.com:80 --> received by apache --> apache becomes a client to s3.example.com:8080, which generates and returns content to apache --> content returned to client by apache
I'm assuming above that the client should never know about or connect directly to s3.example.com:8080 -- if that isn't the case, it becomes much easier.
Apache can do this.
In this case, s3.example.com happens to be the same as s2.example.com, but that's unimportant.
In order for it to work, apache needs to know when it should serve something itself, and when it should act as a proxy server for s3. To be a proxy, you'll want mod_proxy and mod_proxy_http. The mod_proxy "ProxyPass" directive, or the mod_rewrite RewriteRule [P] flag will be needed.
Another thing likely to be needed is for the content produced by the origin server to be modified to be sensible from the eventual client's perspective -- things like links, locations (e.g. for redirects), and cookies are the main candidates. The best plan is to make sure the origin server knows how it is being proxied, and to configure it to produce content appropriate for the "real" client, rather than for the apache client it talks to directly.
If that isn't done, you'll need extra features on the apache side to try to catch any place the original details might leak. The "ProxyPassReverse" directive is the first step; it can modify Location, Content-Location, or URI headers from the origin server. You may also need "ProxyPassReverseCookieDomain" and/or "ProxyPassReverseCookiePath" if the cookie-generating part of the origin server wasn't configured as desired. You may also also need something like the third-party mod_proxy_html to rewrite links (src and href attributes) in the returned html, which may also require other modules or libraries to do it right.
Some or fewer of those directives may not be available, depending on the version of apache being used. That appears to be a secret.
Really, if you control the origin server, and will only be accessing it through the front proxy, configure it so that everything it generates is as if it were the world-facing server. With that, none of the content-transforming directives will be needed.
The most general and, I would claim, easiest way to configure this is by name-based virtual hosting.(I know the OP said virtual hosting wasn't an option in this case, but I'll try to be complete for the rest of the world.)
Logging and directories and the like which are set in the main config are inherited by the virtual hosts, unless overridden there.
The first virtual host is the default one, used when the client-supplied Host: header doesn't match any ServerName or ServerAlias in any VirtualHost sections. Either make it a "please pick a configured site or use a better client" area, or more likely, make it the main one. It's sensible to set ServerName at least
NameVirtualHost [ip] <VirtualHost [ip]> ServerName s1.example.com </VirtualHost> <VirtualHost [ip]> ServerName s2.example.com # url hierarchy on this server --> remote server ProxyPass / http://s3.example.com:8080/ </VirtualHost>But since VirtualHost'ing is out, we need some other way of determining which urls should be proxied and which should be handled directly.
The next most sensible way is to re-implement the relevant bits of virtual hosting using mod_rewrite, conditional on the Host header sent by the client.
RewriteEngine on RewriteCond %{HTTP_HOST} ^s2\.example\.com$ [NC] RewriteRule /(.*) http://s3.example.com:8080/$1 [P]The other ways I can think of are all quite silly, and involve "RewriteCond %{HTTP_HOST}" or its moral equivalent in a server-side script to correctly handle http://s2.example.com/ anyway, so I won't go in to them.
What else might matter...the content transforming, obviously, if you don't configure the origin server to make it unnecessary. Oh, and all of the clients the origin server sees will be from the apache server's address -- quite possibly localhost, in this setup. So that server may want to play logging or other games to produce pretty output. to produce pretty output.
[Mike's question was originally published in Mailbag LG 123.]
Fri Feb 10 13:13:35 2006
Mike Wright (mike.wright
from mail.com)
Hi, I have been trying to figure out exactly what the "cwin" option to the tput command really means.
[Ben] - According to 'man 5 terminfo', it defines a window. According to real-life experience with a variety of xterms, it doesn't do much.
I find that this is generally the case with anything other than a few commands that most xterms have in common. This isn't an area of *nix that has seen much development lately (i.e., the last decade or more) because TclTk and the like have made that kind of text layout, etc., a lot easier _and_ less terminal-dependent than the kind of thing you're trying to do.
What I'm hoping that it will let me do is to create another window in the current terminal using a section of the screen to output listings from different commands that will be executed from numbered menu options. And if the output is several screens then it can be presented a few lines at a time to the user with the option to page down through the many screens of output while not disturbing the menu options at the top of the screen nor the status bars at the bottom of the screen.
I think that you're asking far more of xterms than they can provide. It would be nice if it worked that way, but - as far as I'm aware - it does not.
Why not use several xterms (without decorations) arranged next to each other? I use two tiny xterm windows with a very small font to show my connection status and my mail status in the lower right corner of my screen, something like this:
xterm -geometry 40x10-0-0 -name ppp -fn 6x9 -e pppd call cell-hs & xterm -geometry 40x2-0-100 -name MailTail -e [long command line] &I also have the above xterm names defined in my ~/.icewm/winoptions file (however, unless you're using "icewm" as I do, these should probably go in your ~/.Xresources file):
MailTail.dTitleBar: 0 MailTail.dClose: 0 MailTail.dMinimize: 0 MailTail.dMaximize: 0 MailTail.ignoreTaskBar: 1 MailTail.ignoreWinList: 1 MailTail.ignoreQuickSwitch: 1 ppp.dTitleBar: 0 ppp.dClose: 0 ppp.dMinimize: 0 ppp.dMaximize: 0 ppp.ignoreTaskBar: 1 ppp.ignoreWinList: 1 ppp.ignoreQuickSwitch: 1Obviously, you can stack these however you want to. I find that this is a lot more system-independent than trying to play around with terminfo capabilities.
Fri Feb 3 03:44:51 PST 2006
Roberto (roberto.bacenetti at lombardiacom.it)
I get an "Address already in use" when trying a bind in the following situation:
a board with an ethernet and a ppp connection:
when the board starts only the ethernet interface is on, and
the program successfully binds to the specified port, and is able to accept
connections; at some point the partner disconnects and a GPRS PPP connection
is established, the old bind is already there and the program can accept a connection,
when however the connection is closed any bind will fail, even after a long
time has elapsed.
[[[Neil]]] - Reading this again, it sounds as though you are trying to bind to the same port, while the original program is running. If you have bound a socket it will stay bound, even if it has accepted a connection, which has subsequently closed.
I haven't got my reference books handy, but IIRC, you bind() and listen() on one socket, then accept() creates a second socket. The far end disconnecting closes the second socket. If you want to bind to the the original port again, you have to close the first socket also.
i wrote a test program which binds a socket to a specific interface
and port:
well with PPP on bind always fails.
[[[Neil]]] - Is PPP relevant here? Do you get the same failure with only the ethernet connection?
Can somone explain this ?
[Neil] - Do answers 2.7and 4.5 in the Unix Socket FAQ answer your question?
http://www.faqs.org/faqs/unix-faq/socket/[[Roberto]] - It' not a matter of time delay, the error is persistent and I'm using SO_REUSE_ADDR
[[[[Neil]]] - netstat -tulp should tell you which program is already listening on that socket.
thanks
Roberto
Sun Feb 5 06:16:43 PST 2006
Mike Orr (sluggoster at gmail.com)
What was that program to view webcams on Linux? My friend in the UK (the one mentioned in the iRiver thread) wants to videoconference. He's been bugging me to get a webcam for months but I kept telling him it's such a pain on Linux. Of course he doesn't understand this. "Just plug the camera in and put the CD in the drive, and it installs itself." Yes, on Windows.
I found a webcam HOWTO on linux.com http://www.linux.com/howtos/Webcam-HOWTO/index.shtml and it says some hundred models are supported, but it looks like installing the hardware is only the first part of the problem. Everyone I know who uses webcams transmits them through Yahoo Messenger. There's no like "Internet camera protocol" so you can just attach the camera to a daemon listening on a socket, and view somebody else's camera the same way? The HOWTO mentions camE and Xawtv ('webcam' component), which uploads frames to a website. That's the Linux way to project your webcam to the world? But it seems like it's only good for getting the latest still on a webpage, not for watching a movie. And how do you integrate sound with this?
[Vinayak] - Ayttm has had Webcam support for quite a while now AFAIK. I think the other IM such as everybuddy which use libyahoo2 have webcam support as well.[Jimmy] - GnomeMeeting (http://www.gnomemeeting.org/) is probably the best known video conferencing app for Linux. There's also a fork of Gaim that has voice and video support (http://gaim-vv.sourceforge.net/).
Thu Feb 9 14:17:15 PST 2006
Jim Doutt (jdoutt-at-whoi-dot-edu)
I am backing up an old DOS disk. It had several 'pseudo' drives (K:, L:) implemented under 'drvspace', which created a file for each drive and treated the contents of the file as a disk.
Using an ISA to USB adapter, I plugged the drive into my Fedora core 3 system and created a image of the whole partition .
dd if=/def/sda1 of=bkup.img
I then did a loopback mount of that image file 'bkup.img'.
mount -o loop=/dev/loop3 TI_Travelmate_sda1_windows_20060206.img zz
Great...I can see the DOS files in that image. I also see the files drvspace.000, and drvspace.001 which correspond to my K: and L: drives.
I would like to see the files inside these drvspace files. I have read over dmsdos, but as far as I can tell it was never ported to the 2.6 kernel. I did find a reference to doing a loopback mount using ',cvf_type' mount -o loop=/dev/loop2,cvf_type=dblspace dblspace.001 ../q2 I tried this, and no errors were reported with the mount. However the files and directories had funny names (e.g. ?????.??? etc. ) so the mount was not done properly
Is there a way to do this under LINUX?
[Rick] - I think your only direct access under Linux to those files will be to use the real Microsoft drvspace.bin driver under the "dosemu" emulator. This apparently works well enough, and is detailed here:
http://trillian.randomstuff.org.uk/~stephen/linux/msfilesys.shtml
Over the longer term, you are strongly advised to extract those files from compressed storage, if you care about them. Not only is DriveSpace (and DoubleSpace) pretty unreliable -- and antique -- but also it's just way too darned much trouble to deal with this stuff on an ongoing basis, in my opinion. Good luck!
Tue Feb 28 03:57:15 PST 2006
J. Bakshi (j.bakshi at 1net.gr)
Hi list,
there are some sites which can send SMS to mobile. Generally these sites send SMS based on online operation. there are some microsoft based S/W (limited period trial version) too which allow you to compose your messages offline and then send it after connecting with the net; just like SMTP :-) [though I have not tried anything as my box is debian] BUT is there any such Linux based tool allowing offline SMS composing and sending all after getting net connection ??
[Thomas] -
[n6tadam at workstation ~]$ apt-cache search --names-only sms sms-pl - Send SMs via Polish GSM operators smsclient - A program for sending short messages (SM / SMS) smssend - Utility to send SMS messages to GSM mobile phones smstools - SMS Server Tools for GSM modems
[[jbakshi]] - Thanks a lot Thomas.
[Jimmy] - You've been asking questions here for a while, so this won't come as a surprise: you need to provide more information :)
Short answer: yes, there is software for Linux that will allow you to compose and send SMS messages:
http://tuxmobil.org/phones_linux_sms.htmlLong answer: In fact, there are three main ways of doing this: via a web interface, mobile phone, and any GSM capable modem. (There are other ways; ICQ for Windows, for example, once had a way of sending SMS via ICQ, but AFAICT that has been discontinued). Heck, you can even run your own SMS (and WAP) gateway on Linux: http://www.kannel.org/ or http://smscgw.ccamp.de/
Web interfaces: I mentioned that you needed to provide more information - which website do you want to use, or, failing that, which network(s) do you want to send to? These programs are basically screen scrapers, and need to be aware of the layout of the site you want to use. smssend http://zekiller.skytech.org/smssend_menu.html), for example, can use several operator's websites, as can the Perl module WWW::SMS (http://search.cpan.org/~eim/WWW-SMS/) - they may not be configured for the network you want to use, however. SMTP2SMS seems
to be configured for Indian providers, so maybe that's what you want? https://sourceforge.net/projects/smtp2sms/If you want to send messages using your mobile:
- Gnokii: http://www.gnokii.org/ (supports Nokia specific features, though most basic features can be used with any GSM-capable mobile)
- Gammu: http://www.gammu.net/ (Fork of Gnokii, supports some things Gnokii doesn't)
- KMobileTools: http://kmobiletools.berlios.de/
- Gnome Phone Manager: http://usefulinc.com/software/phonemgr/
Using a GSM modem: I can't find the software I used to use, but GSMlib (http://www.pxh.de/fs/gsmlib/) provided the functionality it used.
KXicq2 (http://www.kxicq.org/), an ICQ client for KDE, has support for sending SMS - I'm pretty sure Kopete and Gaim have plugins to do the same. There's even a project that allows a mobile to be mounted as a file system (http://www.gammu.net/projects/snofs.php) that is planning support for sending SMS this way.
HTH
Sat Feb 4 19:40:47 PST 2006
Chris Gianakopoulos (cgianakop
at 1stconnect.com)
Hi Gang,
Here is my latest 2 cent tip for the year (I hope I have more coming).
I've been stuggling on how to get my iRiver mp3 player to interpoerate with my Linux system. The purpose of this posting is to share my results. I have an IFP-800 series player, and it has been updated with firmware so that it appears as a USB storage type of device. Specifically my model is an IFP-890 player.
My Linux distribution is SuSE 8.2, and here are the steps that I performed.
0. Make sure that USB is enabled for hotplug stuff on your system.
1. Update your iRiver mp3 player with their UMS software. The website is here.
You should see a link titled,
iFP-890(cn)_V185ums.zip (1.4 MBytes)
Go ahead and download this file, and reflash the player using the software provided with your mp3 player.
2. As root, create two files to be stored in /etc/hotplug/usb. The two files are called ifpdev and ifp.usermap. The first file will be executed when you plug your mp3 player into your USB port, and the second file describes the required parameters such as vendor id and model. The two files appear below.
** Begin ifpdev ************************************** #!/bin/sh # /etc/hotplug/usb/ifpdev chgrp usb $DEVICE chmod g+rw $DEVICE End ifpdev ****************************************
** Begin ifp.usermap ********************************* ifpdev 0x0003 0x4102 0x1108 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 ** End ifp.usermap **********************************
3. As root, add an entry in /etc/fstab. The entry appears below.
** Begin fstab entry ********************************* /dev/sda /media/usbDrive auto rw,noauto,user,exec ** End fstab entry **********************************
4. As root, create a directory:
mkdir /media/usbDrive
Now that you've performed all the setup stuff, you just plug your mp3 player into your USB port, and you should hear some beeps indicating recognition of a device being plugged in. Type 'mount /media/usbDrive'.
Now you could access all your music (and whatever else) files :) .
Enjoy!
Chris G.
I forgot to mention in my previous post the source of the script for the hotplug thing. It is http://www.roback.cc/projects/iRiver/.
When I got my mp3 player it didn't have USB filesystem support. I found out about it in a yahoo linux chatroom. Then I beat my head against a wall for about a month after that spending some spare time getting it to interoperate with a linux system. It did pay off. :)
Chris G.
This one is so simple, it's probably always overlooked by many -- or some other alternative solutions are used. There are times (such as viewing a webpage), when one performs "cut-and-paste" from that page, into an editor. I use Vim running in an rxvt. Sometimes (depending on the CR at the ends of the line, there'll be a "stair-case" effect. In the past, I would do (in normal mode):
ggVG=
to reformat (and reindent) the text, but even that's not always the full solution. The "preferred" way is to do this:
:set paste
before you paste the text into vim. Then when you're done, issue:
:set nopaste
... and carry on as normal. It's great. :)
[Kapil] -
I did have this problem (though not with "vim" but "elvis" since that's what I use) and recently found that
:set noaibefore the paste and
:set aiafter the paste seems to do the trick. (For non-vi types to get a clue "ai"="autoindent"). "elvis"/"nvi" don't seem to know the "paste" variable/option.
[Ben] -
I just use ":a", then paste and hit 'Esc'. Works for me.
Hi Everyone,
Recently I had to compare all files in a directory with all files in another
directory to see which of the files had changed and what the differences were.
To run a diff on each file would have taken forever (there were over 300 files in the directory) so I wrote the following script to compare all the files in the current directory with its counterpart in the target directory:
#!/bin/sh # compare_entire_dir.sh # Lets you compare all the files in the current directory with the # files in the specified directory. # # Suramya Tomar (suramya at suramya.com) # 23rd Feb 2006 # # Syntax: ./compare_entire_dir.sh target_directory ############################################################################## for file in *; do echo "Comparing: $file" >> ../compare_results.dat; diff -ibw "$file" $1/$file >> ../compare_results.dat ; done
It worked surprisingly well for me so I thought I should share it with you all. Hope you find it useful.
Thanks,
Suramya
[Thomas] - I just use 'dirdiff', personally.
[[Peter]] Oooh, nice one, thanks! :)
I wonder if the "unison-gtk" folks ever talked to the "dirdiff" folks...
In unison, it'd be nice to be able to take a quick look-see sometimes, to figure out what actually changed in the files (the way dirdiff shows when you double-click on it).
unison works nicely across ssh, that's why I tend to use it a lot for syncing directory trees (at the time, it seemed easier to pick up and understand than rsync).
[Faber] - I just use 'diff', personally.
[Ben] - I just hit 'Ctl-x d' in Midnight Commander. But Faber's method is definitely more portable.
[[Suramya]] - Umm.. I did use diff to make the actual comparison, the script just loops through each file in the current directory and runs a diff of it against the same file name in the target directory.
[[[Ben]]] - Sure, that was very clear from your script. However, 'diff' is one of those utilities that can take either files _or_ directories as arguments.
Here's an example of how it works:
ben at Fenrir:~$ mkdir /tmp/foo /tmp/bar ben at Fenrir:~$ for n in {a..z}.txt; do cp /etc/hosts /tmp/foo/$n; done ben at Fenrir:~$ cp /tmp/foo/{b..y}.txt /tmp/bar ben at Fenrir:~$ echo >> /tmp/bar/y.txt ben at Fenrir:~$ echo >> /tmp/foo/b.txtSo, I've just created a 'foo' and a 'bar' directory in '/tmp', created a list of files in 'foo' (all copies of my '/etc/hosts'), copied the list (except for two files) to 'bar', and slightly modified one file in each directory. Ready? Here we go:
ben at Fenrir:~$ diff /tmp/foo /tmp/bar Only in /tmp/foo: a.txt diff /tmp/foo/b.txt /tmp/bar/b.txt 34d33 < diff /tmp/foo/y.txt /tmp/bar/y.txt 33a34 > Only in /tmp/foo: z.txt ben at Fenrir:~$'diff' shows the results of all the differences - both in the list of files and in the files themselves. Pretty good little prog, hey? :)
[[[[Martin]]]] - Didn't know diff could do dirs as well as files... You learn summat new every day... ;)
[[[[Karl-Heinz]]]] - It even has a "-r" flag for recursive diff down the dir-tree (or would that be up as for real trees?)
[[[[Suramya]]]] - ahh.. didn't know that... Thanks for the info.
This also proves the theory that the more you share/teach the more you learn 'cause if I hadn't shared my script I wouldn't have found out that diff supports directories. :)
Thanks,
Suramya
[[[[[Ben]]]]] - I couldn't agree more. I always tell my students to ask lots of questions, even if they seem silly. Discovering the misconceptions they have is just as important as the understanding they're getting from being in class, and perhaps even a bit more than that; once they have the correct perspective, then even their wild guesses are likely to be right.
What happened to Mr. Okopnik's Perl guru Woomert Foonly? I was reading back issues of LG and was quite impressed with the stories showcasing the interesting data-munging features offered by Perl, as well as the amusing storylines; are any new stories going to be written?
[Ben] Um... well... good question, Brad. I've been waiting for inspiration to strike, but I seem to be having a long dry spell, inspiration-wise. In fact, I started a story about Woomert and Frink a while back, ran into a major plot snag (what kind of a problem can aliens from another universe have that can be solved with Perl???), and... well, there it's sat, ever since. I've tried writing some other W&F stories a couple of times, but got nowhere.
However, the occasional reminders are useful and stimulating. If another Woomert story comes out in the near future, it'll be your fault. :)
Talkback: Discuss this article with The Answer Gang
Kat likes to tell people she's one of the youngest people to have learned to program using punchcards on a mainframe (back in '83); but the truth is that since then, despite many hours in front of various computer screens, she's a computer user rather than a computer programmer. When away from the keyboard, her hands have been found full of knitting needles, various pens, henna, upholsterer's shears, and a pneumatic scaler.