LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-09-2011, 06:11 PM   #1
spoovy
Member
 
Registered: Feb 2010
Location: London, UK
Distribution: Scientific, Ubuntu, Fedora
Posts: 373

Rep: Reputation: 43
Anyone want to set me a scripting task?


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.
Old 02-09-2011, 07:08 PM   #2
dc_eros
Member
 
Registered: Nov 2006
Distribution: Slackware
Posts: 294

Rep: Reputation: 39
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

Here is my outdated project in github: https://github.com/lysender/mass-mailer

I have not pushed yet the file based locking logic yet since I feel lazy now
 
Old 02-09-2011, 08:18 PM   #3
kurumi
Member
 
Registered: Apr 2010
Posts: 228

Rep: Reputation: 53
Quote:
Originally Posted by spoovy View Post
I'm learning shell scripting,
I suggest taking up a programming language instead. Learn Ruby or Python.
 
0 members found this post helpful.
Old 02-09-2011, 09:18 PM   #4
brixtoncalling
Member
 
Registered: Jul 2008
Location: British Columbia
Distribution: Slackware current
Posts: 403

Rep: Reputation: 67
Quote:
Originally Posted by kurumi View Post
I suggest taking up a programming language instead. Learn Ruby or Python.
I suggest that learning shell scripting is in fact extremely valuable.

Last edited by brixtoncalling; 02-09-2011 at 09:24 PM.
 
2 members found this post helpful.
Old 02-09-2011, 09:18 PM   #5
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Rep: Reputation: Disabled
I suggest C/C++, but php and perl are also good.
 
Old 02-09-2011, 11:29 PM   #6
Julian Andrews
LQ Newbie
 
Registered: Jan 2011
Distribution: Ubuntu
Posts: 21

Rep: Reputation: 13
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.
 
Old 02-10-2011, 06:00 AM   #7
spoovy
Member
 
Registered: Feb 2010
Location: London, UK
Distribution: Scientific, Ubuntu, Fedora
Posts: 373

Original Poster
Rep: Reputation: 43
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.
 
Old 02-10-2011, 08:08 AM   #8
Ramurd
Member
 
Registered: Mar 2009
Location: Rotterdam, the Netherlands
Distribution: Slackwarelinux
Posts: 703

Rep: Reputation: 111Reputation: 111
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.
 
Old 02-11-2011, 05:18 PM   #9
spoovy
Member
 
Registered: Feb 2010
Location: London, UK
Distribution: Scientific, Ubuntu, Fedora
Posts: 373

Original Poster
Rep: Reputation: 43
Cheers Ramurd. Scanning logs is a good one - that's now on the list!

@Julian - what are these utilities you mention for extracting metadata from audio files?
 
Old 02-11-2011, 05:44 PM   #10
Julian Andrews
LQ Newbie
 
Registered: Jan 2011
Distribution: Ubuntu
Posts: 21

Rep: Reputation: 13
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!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Xfce: how to set icon for app in Task List and Cycle Windows? catkin Linux - Desktop 6 12-21-2010 04:52 AM
Task bar no longer shows task Richard Rahl Linux - Newbie 3 04-12-2010 09:39 AM
Bash, Env, Set, Export, Pipes....Scripting dtdionne Programming 6 09-06-2007 01:04 AM
(Bash Scripting) Another set of eyes please merana Programming 3 03-22-2005 04:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration