You are not logged in.

#1 2015-10-21 21:09:17

Horizon_Brave
Operating System: Linux-Nettrix
Registered: 2015-10-18
Posts: 1,473

Script and Program Idea's for Newbies

Hi everyone. As I'm trying to get comfortable with my Linux/Unix scripting, I figured this may be a good place to start and talk with other experts and newbies alike to get some idea's and projects we can work on. Obviously starting small. Perhaps we can compile a list of small script idea's to write?
It's easy to read a book or a website about proper scripting syntax, but until you put it into practice regularly you quite easily forget a lot of it.
So for the newbies out there, what would you want to learn, work on? And do the experts, what are some projects you've been working on, or have any idea's on ways to practice script, bash, shell scripting?


"I have not failed, I have found 10,000 ways that will not work" -Edison

Offline

#2 2015-10-22 03:26:42

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 6,296
Website

Re: Script and Program Idea's for Newbies

Hi Horizon_Brave, thanks for your post. The "Scripts, Tutorials & Tips" section is intended for people to post things that already work that they'd like to share.

While this is an interesting subject, I hope you don't mind me moving it to "Off Topic".


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Introduction to the Bunsenlabs Lithium Desktop

Offline

#3 2015-10-22 05:39:48

gako
Member
Registered: 2015-10-02
Posts: 241

Re: Script and Program Idea's for Newbies

Have many bash functions?
Maybe look through what you already have and start thinking of ways to string things together.
Bash is great this way and it is very useful to be familiar with many commands, builtins, keywords, etc..

It could start with a simple function, then as you play with it adding more features, error checking, and so on, you end
up with a nifty script.

Take a look at some bunsenlabs scripts; they are very well written.
See how they behave and think how you could reuse them in different ways.

I'm currently working on a package query script using dialog.
Have been thinking about starting a thread with it soon, maybe I should.
Started as some simple functions available in a menu but has grown into
a tempfile gargling beast that I probably shouldn't have written in bash.. big_smile

Offline

#4 2015-10-23 22:33:19

Horizon_Brave
Operating System: Linux-Nettrix
Registered: 2015-10-18
Posts: 1,473

Re: Script and Program Idea's for Newbies

Hey great suggestion gako, about the reading of the scripts already loaded... I'm going to start simple like some restart, the bl scripts, etc..


"I have not failed, I have found 10,000 ways that will not work" -Edison

Offline

#5 2015-10-24 07:43:05

ohnonot
...again
Registered: 2015-09-29
Posts: 4,278
Website

Re: Script and Program Idea's for Newbies

horizon brave, you should really take a look at the scripts section of crunchbang forums.
there's so much good stuff there.

Online

#6 2015-10-24 15:22:02

tknomanzr
BL Die Hard
From: Around the Bend
Registered: 2015-09-29
Posts: 1,029

Re: Script and Program Idea's for Newbies

I would consider the topic of how to implement a proper backup strategy to be the top on the list for a new scripter.

Examples would include:
1. Using rsync over ssh to backup to an external machine. Schedule it to run periodically via crontab.
2. Copy files into your dropbox folder.
3. Push certain configs, scripts, etc to a git account.
4. Copy files to a cloud-based service.

However, I won't typically push files that gives details about my internal network, such as ssh to a public account for obvious reasons.

For easier restoration of your system if something does go south on you, consider separating your /home and /root partitions. If you keep everything backed up properly, it then becomes easy to rebuild your /root while /home keeps any configuration changes you have made. I also backup all media to an external machine that runs headless and mount it via a simple sshfs one-liner. This saves me the headache of losing media, etc when configuring, rebuilding, etc my main machine and any test machines I may have running.

For reference, here is a recent conversation from #!'s forums on the topic, using rsync
http://crunchbang.org/forums/viewtopic.php?id=39395

Remember, once you start programatically manipulating files, it is easy to really mess things up. I lost a system once due to an accidental rm -rf in the wrong directory. It made me a believer in proper backups.

Offline

#7 2015-10-26 04:39:44

Bearded_Blunder
Dodging A Bullet
From: Seat: seat0; vc7
Registered: 2015-09-29
Posts: 730

Re: Script and Program Idea's for Newbies

@tknomanzr I rather liked the look of Relax and Recover for backup/disaster recovery, sadly it's not in the Debian repos, though they have links to a .deb for download at the main site downloads page.

Unfortunately things just went boom before I'd got everything set up the way I wanted... so I didn't get as far as experimenting and setting it up or testing.

Why script something clunky myself, when experts have pretty well done all the work including sorting the restore method for me?


Blessed is he who expecteth nothing, for he shall not be disappointed...
If there's an obscure or silly way to break it, but you don't know what.. Just ask me

Offline

#8 2015-10-26 07:04:12

tknomanzr
BL Die Hard
From: Around the Bend
Registered: 2015-09-29
Posts: 1,029

Re: Script and Program Idea's for Newbies

The great thing about GNU/Linux is that you don't have to depend on someone else's tool to get the job done if that is your wish. Rsync is an incredibly powerful tool. One of the best in the Linux toolchest, imo. Rsync plus a crontab entry plus a little bit of setup of the system mailer if you want crontab to send you notifications, takes roughly 15 minutes or so once you understand the tools.

One of the reasons I gave a list of options, is that it is nearly impossible to predict what all a user has access too. I use both rsync and git in my backup strategy. With those two tools, I can completely rebuild a debian openbox system in roughly an hour.

I still consider it a great place to start a scripting adventure, because once my backup strategy is in place, I can move forward with more confidence knowing that if I do really mess something up, I am able to recover from it fairly rapidly. Just my 2 cents.

Last edited by tknomanzr (2015-10-26 07:05:41)

Offline

#9 2015-10-26 15:06:26

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 1,989
Website

Re: Script and Program Idea's for Newbies

Personally I have been trying to script one to transcode water to gold.

Offline

#10 2015-10-26 16:11:15

damo
....moderator....
Registered: 2015-08-20
Posts: 5,542

Re: Script and Program Idea's for Newbies

brontosaurusrex wrote:

Personally I have been trying to script one to transcode water to gold.

You can use

convert -i $H2O -o $Au

`convert` is in the Imagemagick suite of tools. You may have to use `sudo`.


Be Excellent to Each Other...

FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#11 2015-10-26 16:18:33

g33zr
Member
From: State of Confusion
Registered: 2015-09-30
Posts: 281

Re: Script and Program Idea's for Newbies

Didn't work for me. I guess I'll have to install BL on metal (fool's gold?) to get convert to real gold.  wink

See:

[g33zr@imac-linux ~]$ sudo convert -i $H2O -o $Au
[sudo] password for g33zr: 
convert: unrecognized option `-i' @ error/convert.c/ConvertImageCommand/1890.
[g33zr@imac-linux ~]$ 

Don't you just hate those unrecognized options?  tongue


What? Me worry?

Red pill or blue pill?

Offline

#12 2015-10-26 16:24:34

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 1,989
Website

Re: Script and Program Idea's for Newbies

probably missing some of the arguments

  -flatten             flatten water first
  -process arguments   process the gold with a custom drill
  -smush geometry      smush a gold sequence together

Offline

#13 2015-10-26 18:03:06

gako
Member
Registered: 2015-10-02
Posts: 241

Re: Script and Program Idea's for Newbies

tknomanzr wrote:

I still consider it a great place to start a scripting adventure, because once my backup strategy is in place, I can move forward with more confidence knowing that if I do really mess something up, I am able to recover from it fairly rapidly. Just my 2 cents.

Great advice tknomanzr, and good tradition, practice.

As for water to gold, probably some loop to break down the molecule first and build it back up.
Dang I suck at chemistry. Guess I'll just back up my computer for now. ahh.. if only.

Offline

#14 2015-10-26 19:41:52

woodape
Member
Registered: 2015-09-29
Posts: 38

Re: Script and Program Idea's for Newbies

My two cents: Think about using bash to gather command line tools together to perform a specific job.

Trivial stuff:
Think about tasks you perform on files or directories all the time that you need to open a terminal for. Write up these actions into scripts and turn them into custom actions for Thunar or whatever file manager you use - converting documents to PDF's, spreadsheets to CSV's, making scripts executable, appening a bunch of text files into one big file, whatever.

For advanced practice, try and figure out how to use zenity, wpa_supplicant and ip to create your own network manager. Bonus points to make one work with openbox through a pipemenu or via dmenu. Think about the functionality you'd want - know available connections, what network you're connected to, how will you enter passwords for new connections, etc. Bonus points if you can connect to a VPN in the same way. If you don't know how these tools work or what they do specifically, its an opportunity to learn.

Offline

Board footer

Powered by FluxBB