Linux Fu: Shell Scripts In C, C++, And Others

At first glance, it might not seem to make sense to write shell scripts in C/C++. After all, the whole point to a shell script is to knock out something quick and dirty. However, there are cases where you might want to write a quick C program to do something that would be hard to do in a traditional scripting language, perhaps you have a library that makes the job easier, or maybe you just know C and can knock it out faster.

While it is true that C generates executables, so there’s no need for a script, usually, the setup to build an executable is not what you want to spend your time on when you are just trying to get something done. In addition, scripts are largely portable. But sending an executable to someone else is fairly risky — but your in luck because C shell scripts can be shared as… well, as scripts. One option is to use a C interpreter like Cling. This is especially common when you are using something like Jupyter notebook. However, it is another piece of software you need on the user’s system. It would be nice to not depend on anything other than the system C compiler which is most likely gcc.

Luckily, there are a few ways to do this and none of them are especially hard. Even if you don’t want to actually script in C, understanding how to get there can be illustrative.

Continue reading “Linux Fu: Shell Scripts In C, C++, And Others”

Writing Characters Straight To The Linux Framebuffer

These days, working with a display in software is fairly easy. Thanks to the convenience of the modern OS, we’re blessed with graphical user interfaces, where things such as buttons and windows and text are all taken care of for us. Of course, once you start to wander off the beaten track, particularly in embedded systems with no GUI, things can get a little more difficult. For these situations, [JSBattista] wrote some code to blast text directly to the Linux framebuffer.

It’s a project borne out of necessity. Working with a Raspberry Pi with no X server, it was found that the console text size made it difficult to display data. By writing directly to the framebuffer, it would be possible to display text of a larger size without having to implement a full GUI, and overheads could be kept to a minimum.

Working in this manner comes with some limitations. Glyphs are taken from an array in bitmap format, rather than font files. In this case, a font akin to that of the Alien sentry gun interface was chosen, for an attractive sci-fi look. Lowercase characters are currently unimplemented. Testing thus far has been on Raspberry Pi and Beaglebone non-GUI systems, with performance varying depending on platform.

It’s a project we suspect might prove useful to the developers of lightweight embedded systems. It’s something that may take some tweaking and experimentation to implement, but the hacker set rarely shy away from a challenge. If you’re eager to get down and dirty with some heavy programming, this tutorial on Linux graphics will help.

Linux Fu: Interactive SSH Applications

[Drew DeVault] recently wrote up some interesting instructions on how to package up interactive text-based Linux commands for users to access via ssh. At first, this seems simple, but there are quite a few nuances to it and [Drew] does a good job of covering them.

One easy way — but not very versatile — is to create a user and make the program you want to run the default shell. The example used is to make /usr/bin/nethack the shell and now people can log in as that user and play nethack. Simple, right? However, there are better ways to get there.

Continue reading “Linux Fu: Interactive SSH Applications”

Linux Fu: It’s A Trap!

It is easy to think that a Linux shell like Bash is just a way to enter commands at a terminal. But, in fact, it is also a powerful programming language as we’ve seen from projects ranging from web servers to simple utilities to make dangerous commands safer. Like most programming languages, though, there are multiple layers of complexity. You can spend a little time and get by or you can invest more time and learn about the language and, hopefully, write more robust programs.

Continue reading “Linux Fu: It’s A Trap!”

Modern Linux Runs On Ancient Toshiba

While Microsoft no longer supports those of its operating systems that were in heavy use into the early 2000s, support for old hardware is not typically something that you will have to worry about if you run Linux on your machines. Sure, there will be driver issues from time to time, and you might have to do some things by hand, but if you’re using legacy hardware you’ll want a Linux distribution of some sort. Especially if you’re running it on one of the first laptops to ever feature a Pentium processor of any kind.

This is a Toshiba T4900CT which [MingcongBai] has been able to spruce up by installing a simplified version of the AOSC OS Linux distribution. The distribution is known for its simplified user interface, and this particular one runs a “Retro” command-line-only version. Upon startup (which takes over two minutes), the user can view the hardware and software specs: Linux kernel 4.19.67 (released within the past year) on a 75 MHz Intel processor.

Getting old equipment to work, even if the software is available, is a challenge and this one stands out for the historical noteworthiness of the laptop. We didn’t see it connect to the Internet, but if it ever does we still keep Retro Hackaday up specifically for situations like this.

Hackaday Links Column Banner

Hackaday Links: August 4, 2019

Is the hacking community facing a HOPEless future? It may well be, if this report from 2600 Magazine is any indication. The biennial “Hackers On Planet Earth” conference is in serious financial jeopardy after the venue that’s hosted it for years, the Hotel Pennsylvania in Manhattan, announced a three-fold increase in price. Organizers are scrambling to save the conference and they’re asking for the community’s help in brainstorming solutions. Hackaday was at HOPE XI in 2016 and HOPE XII in 2018; let’s HOPE we get to see everyone again in 2020.

If you’ve ever been curious about how a 1970s PROM chip worked, Ken Shirriff has you covered. Or uncovered, as he popped the top off a ceramic MMI 5300 DIP to look at the die within. Closeups of the somewhat cockeyed die reveal its secrets – 1,024 tiny fusible links. Programming was a matter of overloading a particular fuse, turning a 1 into a 0 permanently. It’s a fascinating look at how it used to be done, with Ken’s usual attention to detail in the documentation department.

We had a great Hack Chat this week with Mihir Shah from Royal Circuits. Royal is one of the few quick-turn PCB fabs in the USA, and they specialize in lightning-fast turnaround on bare PCBs and assembled boards. He told us all about this fascinating business, and dropped a link to a side project of his. Called DebuggAR, it’s an augmented reality app that runs on a smartphone and overlays component locations, signal traces, pinouts, and more right over a live image of your board. He’s got a beta going now for iPhone users and would love feedback, so check it out.

With all the cool things you can do with LoRa radios, it’s no wonder that wireless hobbyists have taken to pushing the limits on what the technology can do. The world record distance for a LoRa link was an astonishing 702 km (436 miles). That stood for two years until it was topped, twice in the same day. On July 13th, the record was pushed to 741 km, and a mere five hours later to 766 km. All on a scant 25 mW of power.

Linux distro Manjaro made an unconventional choice regarding which office suite to include, and it’s making some users unhappy. It appears that they’ve dumped LibreOffice from the base install, opting instead to include the closed-source FreeOffice. Worse, FreeOffice doesn’t have support for saving .doc and OpenDocument files; potentially leaving LibreOffice users stranded. Paying for an upgrade to SoftMaker’s Office product can fix that, but that’s hardly free-as-in-beer free. It’s kind of like saying the beer is free, but the mug is an upgrade. UPDATE: It looks like the Manjaro team heard all the feedback and are working on a selector so you can install the office suite of your choice.

Tragic news out of New Hampshire, as amateur radio operator Joe Areyzaga (K1JGA) was killed while trying to dismantle an antenna tower. Local news has coverage with no substantial details, however the hams over on r/amateurradio seem to have the inside line on the cause. It appears the legs of the tower had filled with water over the years, rusting them from the inside out. The tower likely appeared solid to Joe and his friend Mike Rancourt (K1EEE) as they started to climb, but the tower buckled at the weak point and collapsed. K1EEE remains in critical condition after the 40′ (12 m) fall, but K1JGA is now a silent key. The tragedy serves as a reminder to everyone who works on towers to take nothing for granted before starting to climb.

And finally, just for fun, feast your eyes on this movie of the ESA’s Rosetta spacecraft as is makes its flyby of comet 67P/Churyumov–Gerasimenko. It’s stitched together from thousands of images and really makes 67P look like a place, not just a streak of light in the night sky.

Retrotechtacular: The Floppy Disk Orphaned By Linux

About a week ago, Linus Torvalds made a software commit which has an air about it of the end of an era. The code in question contains a few patches to the driver for native floppy disc controllers. What makes it worthy of note is that he remarks that the floppy driver is now orphaned. Its maintainer no longer has working floppy hardware upon which to test the software, and Linus remarks that “I think the driver can be considered pretty much dead from an actual hardware standpoint“, though he does point out that active support remains for USB floppy drives.

It’s a very reasonable view to have arrived at because outside the realm of retrocomputing the physical rather than virtual floppy disk has all but disappeared. It’s well over a decade since they ceased to be fitted to desktop and laptop computers, and where once they were a staple of any office they now exist only in the “save” icon on your wordprocessor. The floppy is dead, and has been for a long time.

The save icon in LibreOffice and other desktop software is probably the last place the floppy exerts a hold over us.
The save icon in LibreOffice and other desktop software is probably the last place the floppy exerts a hold over us.

Still, Linus’ quiet announcement comes as a minor jolt to anyone of A Certain Age for whom the floppy disk and the computer were once inseparable. When your digital life resided not in your phone or on the cloud but in a plastic box of floppies, those disks meant something. There was a social impact to the floppy as well as a technological one, they were a physical token that could contain your treasured ephemeral possessions, a modern-day keepsake locket for the digital age. We may have stopped using them over a decade ago, but somehow they are still a part of our computing DNA.

So while for some of you the Retrotechtacular series is about rare and unusual technology from years past, it’s time to take a look at something ubiquitous that we all think we know. Where did the floppy disk come from, where is it still with us, and aside from that save icon what legacies has it bestowed upon us?

Continue reading “Retrotechtacular: The Floppy Disk Orphaned By Linux”