PDA

View Full Version : Usefull scripts (I wish to learn how to make my own scripts)



Primoz
Dec 7th 2008, 05:55 PM
I recently learned and made some really basic BAT files, just for shutdown and restart.
If I understand correctly the Linux version of BAT files are scripts. So I would like to learn some useful scripts.
From the start, from where do you make them (Kate I suppose?) in which format you save them.
Something like my frined made in BAT file for Vista where he made a "gaming" session BAT that when runed kills everything that you don't need when playing games.

So please if there are any useful scripts that you know, share them with me.
But as I said I would not like to just use preconfigured scripts, but also to make them myself.
Thanks in advance.

toad
Dec 7th 2008, 07:46 PM
Always a handy script to have is one which backs up your email, mozilla, calendar and address folders.

The folders in question vary depending on your setup, mine are in a special partition called /personal which I back up every 15 minutes across two disks (I use this for work, I'm not 'just' paranoid ;)).

Start your bash script with a shebang and take it from there ;D And ask all the questions you want...

Primoz
Dec 7th 2008, 08:43 PM
What's shebang? (#! ?)
Is script equal to BAT? Meaning that I use bash commands to achieve whatever I want...
How would an shutdoen script look like?
maybe something like this:

shabang (whatever that is) shutdown -h now

toad
Dec 7th 2008, 08:50 PM
shebang = http://en.wikipedia.org/wiki/Shebang_(Unix) - in our case #!/bin/bash

BAT? What is BAT?

Try to write a script that backs up your vital data to a separate, safe place. You will need to look a little deeper into the cp command as you only want to copy changes, not everything anew. Other than that it should be straight forward ;)

Feel free to ask questions.

The finished script can then either be incorporated into the booting/shutting down process or be executed on a regular basis using cron - but first for that script :)

Primoz
Dec 7th 2008, 08:57 PM
shebang = http://en.wikipedia.org/wiki/Shebang_(Unix) - in our case #!/bin/bash

BAT? What is BAT?

BAT is an windows batch file which if I understand it correctly it's similar to scripts.
Bat for shutdown of computer:

@echo off
shutdown -s -t 05
msg * Computer will shutdown in 5 seconds.
echo off means that this procedure won't be shown in command prompt.
together with msg * they make of some kind GUI.

sithlord48
Mar 7th 2009, 03:13 PM
yes there basicly equlivent to one another
you would be saving them as a .sh file
and you should be able to find lots of commands for them try using

man <program> to find out arguments and see examples for a program.
also to run a script you

sh <script>.sh