LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-02-2013, 12:56 PM   #1
RigsJuarez
LQ Newbie
 
Registered: Aug 2013
Posts: 3

Rep: Reputation: Disabled
Any shell scripts repository examples?


Hi all,

Is there any web site with common SysAdmin shell scripts repository examples?

I remember there was one with many categorized (file system/networking/processes, etc.) shell scripts but I can't find it anymore.

Regards.
 
Old 09-02-2013, 01:26 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,504

Rep: Reputation: 3992Reputation: 3992Reputation: 3992Reputation: 3992Reputation: 3992Reputation: 3992Reputation: 3992Reputation: 3992Reputation: 3992Reputation: 3992Reputation: 3992
Quote:
Originally Posted by RigsJuarez View Post
Hi all,
Is there any web site with common SysAdmin shell scripts repository examples?

I remember there was one with many categorized (file system/networking/processes, etc.) shell scripts but I can't find it anymore.
Regards.
There are some sites like Hotscripts, and many more you can find with a Google search.
 
Old 09-02-2013, 11:06 PM   #3
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
I keep my common shell scripts in /usr/share/bash, and use this script to "include" the ones I want:
Code:
$ cat /usr/share/bash/include 
#!/bin/bash
# Define the function to include all the programs listed in "$*" from /usr/share/bash
#
# Usage: include function1 {function2 ...}
#
# Note: This function assumes that any function to be included may be an executable script
#       and searches $PATH for any match before looking in the location array entries.
#
# Define the include function if it's not already defined
if [ "$(type -t include)" != "function" ]
then
  include ()
  {
    local d f abort loc found
    local -a locations
# This is the array naming the locations to be searched
    locations=("/usr/share/bash" "${HOME}/Scripts/Bash")
    abort=0
    for f in "$@"
    do
      loc=$(type -P "${f}")
      if [ -z "${loc}" ]
      then
        found=0
        for d in "${locations[@]}"
        do
          if [ -f "${d}/${f}" ]
          then
            . "${d}/${f}"
            found=1
            break
          fi
        done
        if [[ ${found} == 0 ]]
        then
          echo Error: The bash include file \"${f}"\" could not be found." > /dev/stderr
          abort=$((++abort))
        fi
      else
        . "${loc}"
      fi
    done
    [ ${abort} -gt 0 ] && exit ${abort}
  }
fi
Here's an example of how I use it:
Code:
# Load the local function definitions
. /usr/share/bash/include
include define_colors \
        sucmd \
        connect_using_nmcli_to \
        vg_activate \
        mount_noauto \
        mount_cifs \
        mount_iso
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Shell scripts repository RigsJuarez Programming 3 09-06-2013 01:55 PM
LXer: Linux shell: understanding Umask with examples LXer Syndicated Linux News 0 12-05-2012 11:12 PM
LXer: New Blog Post : GitHub Repository For Pygame Examples LXer Syndicated Linux News 0 12-17-2011 08:41 PM
writtign my own linux shell using BASH, guidelines? examples? thx cocchiararo Programming 33 05-16-2008 05:47 PM
Looking for a good list of shell commands with examples jk1 Linux - Newbie 4 06-11-2002 08:09 PM


All times are GMT -5. The time now is 06:56 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration