SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm learning shell scripting, and really starting to get into it. I don't have much imagination though, and what would be good would be if someone could throw some problems at me - typical linux sysadmin type things maybe, but not too difficult obviously.
Sorry if this sounds a bit daft but as I say I have very little imagination, i'm better at solving problems than thinking them up!
Click here to see the post LQ members have rated as the most helpful post in this thread.
Well, I was scripting in PHP to send mass mailer via cron every minute. Since cron may overlap, I put a lock file to ensure that only one instance of the batch mail sender (PHP) is running. It is pretty easy, but I wanted it to be at bash script level. Since I can only do it in PHP, I just use the bash script as the php script wrapper.
How can we do a file based locking so that the PHP script will not be called if the lock is not yet deleted. Maybe we could help each other
You could try to write a script to sort a bunch of music files (flac, ogg, or mp3, your choice) based on their metadata into folders. I had to do this a while ago, and the task was initially simple, but there was a lot of room for potential expansion so it was a good learning project. Initially, you could just try to sort files into folders by artist or album, or the like.
There are command line utilities that can get you the metadata, so it would give you practice with the most important aspect of scripting - processing input from third party programs.
Possible refinements could include:
Configfurable directory structure,
Conversion of files into other formats while retaining metadata,
Search of whole computer for unsorted files
Metadata completion via some online db maybe?
Anyway, it's a fun project!
As an aside, if you want to learn a real programming language, I say take up Python - no one ever regrets choosing python.
Thanks Julian that sounds like a good one. I do have countless music files that need sorting so I will definately give this a go. I was vaguely planning on setting up a database for them so I can maybe build that in as well. Cheers.
BTW I have a python book on order, which will be next on the hitlist after i've put a few genuinely useful bash scripts together. But lets keep to shell scripts at the moment - don't want to start another "which programming language is best for noobs" thread.
Great job starting on scripting. It's farily easy, teaches you Linux and some of the main logics of programming. All in all a good choice to start to learn shell scripting.
I learned it the other way around (first C, then scripting) and both are still quite profitable to me.
If you're more in for a bit of fun, you could try to script a one-armed bandit
Or a menu for your most common sysadmin tasks (create/delete users, check log files, etc)
A script that you can put in cron that scans your logs for 1) strange incoming connections (hackers?) 2) new mail 3) kernel warnings
The latter will learn you a bit about syslogd as well, so you learn to split up your messages across various log files, just like you'd like them to be recorded and where.
I could go on for a little while, but I think you can get some ideas of what is possible with shell scripting. And indeed: the sky is pretty much the limit (well, actually performance), so it's hard to get a nice good choice.
Good luck and have fun scripting! If you'd like feedback on your script(s), I'm more than willing to give some.
For flac there's a utility called metaflac which comes with the official 'flac' package. For mp3 you can use 'lame'. For OGG, you'll want 'vorbis-tools'. They all have different interfaces, so you'll want to pick just one to start with - then potentially expand. Good luck!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.