message = This is recommended only for advanced users, proceed with caution.}}The scripts below are now included in the Amahi [https://www.amahi.org/apps/terminal-scripts Terminal Scripts] application. You might also find [https://www.amahi.org/apps/shellcheck ShellCheck] helpful when developing scripts.
Use of script files provides many useful results. Below is a small collection that should enhance your command line experience.
==Disk SpaceREADME1ST =={{Code|#!<b><u>Terminal Scripts Application README FILE</binu></bashb> The following scripts are included:* automysqlbackup: Backup multiple MySQL databases on a given schedule.* diskspace: Displays graphical depiction of all drive space used and remaining.* dnflog: Shows latest Fedora updates that have been applied.* dsalert: Sends email if a disk has used a set percentage of space. Requires the system have outgoing email capability. * folderspace: Displays how much space a specific folder occupies.* hdaupdates: Shows latest Amahi updates to your HDA.* smartchk: Provides health status of disks drives set in the script.* systeminfo: Displays various criteria about the system, to include host name, IP address, uptime, etc.* weather: Shows weather for a given location as preset in the script. ALL the above scripts may require some modification for your system. * systeminfo and weather script has a variable that must be changed for your geographical area.* smartchk requires modification to list all mounted hard disk drives in your system.* automysqlbackup has various settings will need adjusted for your system. See the [[https://wiki.amahi.org/index.php/Database_Backup:automysqlbackup]] page for details. <b><u>Dependencies Installed for Scripts</u></b> * sysinfo: pciutils and procinfo * smartchk: smartmontools * dsalert: smartmontools
<b><u>dos2unix (installed with this application)</u></b>
What is it?
<blockquote>dos2unix is a tool to convert text files from DOS line endings (carriage return + line feed) to Unix line endings (line feed). It is also capable of conversion between UTF-16 to UTF-8. Invoking the unix2dos command can be used to convert from Unix to DOS. This tool comes in handy when sharing files between Windows and Linux machines. </blockquote>
Why would I need this tool?
<blockquote>While editing files on a machine running some form of Windows and uploading them to a Linux server is convenient, it can cause unforeseen complications. Windows-based text editors put special characters at the end of lines to denote a line return or newline. Normally harmless, some applications on a Linux server cannot understand these characters and can cause the service to not respond correctly. There is a simple way to correct this problem: dos2unix.</blockquote>
The dos2unix command is a simple way to make sure that files that have been edited and uploaded from a Windows machine to a Linux machine work and behave correctly.
<nowiki>|</nowiki> sed -n '/Currently:/ s/.*: \(.*\): \([0-9]*\)\([CF]\).*/\2°\3, \1/p'</pre>
curl === HDA Updates === Here is a simple script that displays all of the file updates and additions made to your hda and the date they happened. It simply reads the hda-s httpupdates.log file and parses out only the relevant changes. I use this script periodically so I can see what might have changed recently. '''Installation''' Log into your hda and create a bin directory under your home directory (if you don't already have one). The reason for this is that ~/bin is already in your $PATH when you log in, so it will automatically find any scripts you put there: cd /usr/rssbin Open up your favorite editor (I suggest gedit for this) and copy the code that follows into the editor.accuweatherSave the file as '''hda-updates''' (or whatever you want to name it) and exit the editor.com '''Code:'''<!--<pre>#!/usr/bin/rsspython## Dump update information from /liveweather_rssvar/log/hda-updates.asp\?metric\<nowiki>log#!/usr/bin/python## Display the date and files that were modified/installed.## Reads the hda-updates log file and parses out just the file updates/additions.# It helps to see what has been modified and when.## radioz# 11/8/2010#log =<'/var/log/nowiki>${METRIC}\&locCode\<nowiki>hda-updates.log'f = open(log, 'r')lines = f.readlines()f.close()gotUpdates = FalsefirstUpdate = FalsedateInfo = ''for ll in lines : l = ll.strip() # Ignore dependency heading if l == 'Installing for dependencies:' : continue if l == '' : # A blank line terminates the updates for a particular date if gotUpdates : # Display a blank line between dates print gotUpdates = False continue if gotUpdates : if firstUpdate : # Display the date above the first update print '%s:' % dateInfo firstUpdate = False # Reformat the file info slightly updateInfo = l.split() print ' %-16s %-6s %-20s %-16s %-5s %s' % (tuple(updateInfo)) if 'hda update attempt' in l : # This header appears once per hour in the log. Very few represent real updates. # Save the date information in case this is a real update. dateInfo = ' '.join(l.split()[5:]) if 'Updating:' in l : # This is a real update, set up the flags gotUpdates = True firstUpdate =True</nowikipre>-->$LOCCOD \<nowikipre>|<#!/usr/bin/python## Dump update information from /var/log/hda-updates.log#!/usr/bin/python## Display the date and files that were modified/nowiki> sed installed.## Reads the hda-n updates log file and parses out just the file updates/additions.# It helps to see what has been modified and when.## radioz# 11/8/2010## Updated by bigfoot65# 9/26/2014#log = '/Currently:var/ slog/hda-updates.*: log'line = '==============================================================================='head = 'Package Arch Version Repository Size'cyan = '\033[1;36m'blue = '\033[1;34m'purple = '\033[1;35m'white = '\033[1;37m'print blue + line + whiteprint cyan + head + whiteprint blue + line + whitef = open(log, 'r')lines = f.readlines()f.*\close()gotUpdates = FalsefirstUpdate = FalsedateInfo = ''for ll in lines : \ l = ll.strip() # Ignore dependency heading if l == 'Installing for dependencies:' : continue if l == '' : # A blank line terminates the updates for a particular date if gotUpdates : gotUpdates = False continue if gotUpdates : if firstUpdate : # Display the date above the first update print '%s:' % dateInfo firstUpdate = False # Reformat the file info slightly updateInfo = l.split([0-9]*\)\ print purple + l + white print blue + line + white if 'hda update attempt' in l : # This header appears once per hour in the log. Very few represent real updates. # Save the date information in case this is a real update. dateInfo = ' '.join(l.split()[CF5:]\) if 'Updating:' in l : # This is a real update, set up the flags gotUpdates = True firstUpdate = True</pre> Make the file executable: chmod +x hda-updates Now you can run it. '''Example''' hda-updates Here is a snippet of its output on my system: <pre>===============================================================================Package Arch Version Repository Size===============================================================================Fri Sep 5 21:01:37 CDT 2014:amahi-anywhere x86_64 1.35-1 amahi 1.8 M===============================================================================Mon Sep 15 23:03:04 CDT 2014:hda-ctl x86_64 5.*4.0-1 amahi 154 k===============================================================================</pre> === Fedora Updates ===<pre>#!/usr/bin/bashhead=' PACKAGE NAME\t\t\t\2°t\3, tDATE'line='============================================= ==============================='cyan='\033[1;36m'blue='\033[1;34m'purple='\033[1;35m'white='\033[1/p;37m'echo -e ${blue}${line}${white}echo -e ${purple}${head}${white}echo -e ${blue}${line}${cyan}rpm -qa --last | headecho -e ${white}</pre>