SlideShare uma empresa Scribd logo
1 de 6
#!/bin/bash
# /usr/local/bin/mkscript
# Copyright 2000, Chris F.A. Johnson
# Released under the terms of the GNU General Public License
# USAGE: mkscript command
# fix permissions for script "command"-sh in /usr/local/bin/scripts
# create it if it doesn't exist
# link it to "command" in /usr/local/bin
die()
{
exitcode=$1
shift
if [ "$*" ]
then
echo "$*"
fi
exit ${exitcode:-1}
}
version() {
echo $version
}
usage()
{
echo "
$progname -
USAGE: $progname [OPTIONS]
OPTIONS:
-d DESC - description
-f - force=1 ;; # replace file if it exists
-r - remove=1 ;; # remove script if is exists
-R - remove=2 ;; # not used
-a OPTS - options that take arguments
-o OPTS - options that do not take arguments
-u - user=$OPTARG ;;
-a OPTS - argopts=$OPTARG ;;
-h - help: print this message
-H - help: print more detailed message
-v - verbose:
-V - print version information
Copyright 2001, Chris F.A. Johnson
"
}
put_header()
{
echo "#!/bin/bash
# `date`
# NAME: $command
# Copyright `date +%Y`, $author
# Released under the terms of the GNU General Public License
"
}
func_die()
{
echo 'die() {
exitcode=$1
shift
if [ "$*" ]
then
echo "$*"
fi
exit ${exitcode:-1}
}
'
}
func_version()
{
echo 'version()
{
echo " $progname, version $version
Copyright $copyright, $author $email
This is free software, released under the terms of the GNU General
Public License. There is NO warranty; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
"
}
'
}
func_usage()
{
echo "usage()
{
echo " $progname - $description
USAGE: $progname [OPTIONS]
OPTIONS:
""
{
n=0
while [ $n -lt ${#argopts} ]
do
l=${argopts:$n:1}
echo " -$l arg - "
n=$(( $n + 1 ))
done
n=0
while [ $n -lt ${#opts} ]
do
l=${opts:$n:1}
echo " -$l - "
n=$(( $n + 1 ))
done
} | sort
echo "
[ $longusage -eq 1 ] &&
echo "
-h - help: print shorter help message
-H - help: print this message" ||
echo "
-h - help: print this message
-H - help: print more detailed message"
echo " -v - verbose:
-V - print version information
"
[ $longusage -eq 1 ] &&
version ||
echo "
Copyright $copyright, $author
"
}
"
}
put_vars()
{
echo "
description="$description"
verbose=0
longusage=0
version="1.0"
copyright=$copyright
author="$author""
echo 'progname=${0##*/}'
}
put_getopts()
{
[ -n "$argopts" ] && {
o=0
while [ $o -lt ${#argopts} ]
do
l=${argopts:$o:1}
[ "$l" ] && getopts="$getopts${NL} $l) ${l}_arg=$OPTARG ;;"
optstr=${optstr}${l}:
o=$(( $o + 1 ))
done
}
[ -n "$opts" ] && {
o=0
while [ $o -lt ${#opts} ]
do
l=${opts:$o:1}
[ "$l" ] && getopts="$getopts${NL} $l) ${l}_opt=1 ;;"
optstr=${optstr}${l}
o=$(( $o + 1 ))
done
}
echo "
while getopts vVhH-:$optstr var
do
case $var in"
echo "$getopts" | sort
echo '
-) case $OPTARG in
help) usage; exit ;;
help_long) longusage=1; usage; exit ;;
version) version; exit ;;
esac
;;
h) usage; exit ;;
H) longusage=1; usage; exit ;;
v) verbose=$(( $verbose + 1 )) ;;
V) version; exit ;;
*);;
esac
done
shift $(( $OPTIND - 1 ))
'
}
bindir="/usr/local/bin"
shdir="${bindir}/scripts"
version="1.1"
verbose=0
force=0
remove=0
longusage=0
progname=${0##*/}
NL=$'n'
while getopts vVhHfro:a:d:u: var
do
case "$var" in
d) description=$OPTARG ;;
f) force=1 ;; # replace file if it exists
r) remove=1 ;;
R) remove=2 ;;
a) argopts=$OPTARG ;;
o) opts=$OPTARG ;;
u) user=$OPTARG ;;
a) argopts=$OPTARG ;;
v) verbose=$(( $verbose + 1 )) ;;
V) version; exit ;;
h) usage; exit ;;
H) longusage=1; usage; exit ;;
*);;
esac
done
shift $(( $OPTIND - 1 ))
echo *=$*
echo opts=$opts
echo argopts=$argopts
if [ ! "$1" ]
then
die 1 "${progname}: command name required"
fi
cd ${shdir}
command=${1}
shcommand=${command}-sh
author="`grep -w ^$USER /etc/passwd | cut -d: -f5 | cut -d "," -f1`"
copyright=`date +%Y`
if [ $remove -ge 1 ]
then
if [ -f "$shcommand" -a $remove -eq 2 ]
then
rm -f $shcommand
fi
if [ -f $bindir/$command ]
then
rm -f $bindir/$command
fi
## add code to remove any other aliases in /usr/local/bin
exit
fi
if [ ! -f $bindir/$command ]
then
touch $shdir/$shcommand
cd $bindir
ln -s $shdir/$shcommand $command
fi
if [ -f "$shcommand" -a $force = 0 ];then
echo " $shcommand already exists
Use -f to replace it"
exit
fi
(
put_header
func_version
func_usage
put_vars
{
[ -n "$argopts" ] && {
echo $argopts | while read -n1 l
do
[ "$l" ] && echo "${l}_arg="
done
}
[ -n "$opts" ] && {
echo $opts | while read -n1 l
do
[ "$l" ] && echo "${l}_opt=0"
done
}
} | sort
put_getopts
) > ${shdir}/$shcommand
chown ${user:-$USER} ${shdir}/$shcommand
chmod a+x ${shdir}/${shcommand}
cd $bindir
pwd
ln -fs scripts/$shcommand $command
ls -l ${shdir}/$shcommand
if [ $remove -ge 1 ]
then
if [ -f "$shcommand" -a $remove -eq 2 ]
then
rm -f $shcommand
fi
if [ -f $bindir/$command ]
then
rm -f $bindir/$command
fi
## add code to remove any other aliases in /usr/local/bin
exit
fi
if [ ! -f $bindir/$command ]
then
touch $shdir/$shcommand
cd $bindir
ln -s $shdir/$shcommand $command
fi
if [ -f "$shcommand" -a $force = 0 ];then
echo " $shcommand already exists
Use -f to replace it"
exit
fi
(
put_header
func_version
func_usage
put_vars
{
[ -n "$argopts" ] && {
echo $argopts | while read -n1 l
do
[ "$l" ] && echo "${l}_arg="
done
}
[ -n "$opts" ] && {
echo $opts | while read -n1 l
do
[ "$l" ] && echo "${l}_opt=0"
done
}
} | sort
put_getopts
) > ${shdir}/$shcommand
chown ${user:-$USER} ${shdir}/$shcommand
chmod a+x ${shdir}/${shcommand}
cd $bindir
pwd
ln -fs scripts/$shcommand $command
ls -l ${shdir}/$shcommand

Mais conteúdo relacionado

Mais procurados

Logrotate sh
Logrotate shLogrotate sh
Logrotate sh
Ben Pope
 
2014 database - course 2 - php
2014 database - course 2 - php2014 database - course 2 - php
2014 database - course 2 - php
Hung-yu Lin
 
The groovy puzzlers (as Presented at JavaOne 2014)
The groovy puzzlers (as Presented at JavaOne 2014)The groovy puzzlers (as Presented at JavaOne 2014)
The groovy puzzlers (as Presented at JavaOne 2014)
GroovyPuzzlers
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
Abhay Sapru
 
Huong dan cai dat hadoop
Huong dan cai dat hadoopHuong dan cai dat hadoop
Huong dan cai dat hadoop
Quỳnh Phan
 

Mais procurados (20)

Parsing JSON with a single regex
Parsing JSON with a single regexParsing JSON with a single regex
Parsing JSON with a single regex
 
Logrotate sh
Logrotate shLogrotate sh
Logrotate sh
 
spug_2008-08
spug_2008-08spug_2008-08
spug_2008-08
 
Advanced Shell Scripting
Advanced Shell ScriptingAdvanced Shell Scripting
Advanced Shell Scripting
 
WordPress Cuztom Helper
WordPress Cuztom HelperWordPress Cuztom Helper
WordPress Cuztom Helper
 
2014 database - course 2 - php
2014 database - course 2 - php2014 database - course 2 - php
2014 database - course 2 - php
 
Yahoo! JAPANとKotlin
Yahoo! JAPANとKotlinYahoo! JAPANとKotlin
Yahoo! JAPANとKotlin
 
Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本
 
My First Ruby
My First RubyMy First Ruby
My First Ruby
 
Bag of tricks
Bag of tricksBag of tricks
Bag of tricks
 
An Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackAn Elephant of a Different Colour: Hack
An Elephant of a Different Colour: Hack
 
Ch3(working with file)
Ch3(working with file)Ch3(working with file)
Ch3(working with file)
 
Perl Fitxers i Directoris
Perl Fitxers i DirectorisPerl Fitxers i Directoris
Perl Fitxers i Directoris
 
Simplifying code monster to elegant in n 5 steps
Simplifying code  monster to elegant in n 5 stepsSimplifying code  monster to elegant in n 5 steps
Simplifying code monster to elegant in n 5 steps
 
Oo Perl
Oo PerlOo Perl
Oo Perl
 
MuseScore MusicHackDay Presentation
MuseScore MusicHackDay PresentationMuseScore MusicHackDay Presentation
MuseScore MusicHackDay Presentation
 
The groovy puzzlers (as Presented at JavaOne 2014)
The groovy puzzlers (as Presented at JavaOne 2014)The groovy puzzlers (as Presented at JavaOne 2014)
The groovy puzzlers (as Presented at JavaOne 2014)
 
Taking Perl to Eleven with Higher-Order Functions
Taking Perl to Eleven with Higher-Order FunctionsTaking Perl to Eleven with Higher-Order Functions
Taking Perl to Eleven with Higher-Order Functions
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
 
Huong dan cai dat hadoop
Huong dan cai dat hadoopHuong dan cai dat hadoop
Huong dan cai dat hadoop
 

Destaque (15)

Getfilestruct zbksh(1)
Getfilestruct zbksh(1)Getfilestruct zbksh(1)
Getfilestruct zbksh(1)
 
Analysis of the Performance of Sea Level Stations at Haiti
Analysis of the Performance of Sea Level Stations at HaitiAnalysis of the Performance of Sea Level Stations at Haiti
Analysis of the Performance of Sea Level Stations at Haiti
 
Firewall
FirewallFirewall
Firewall
 
Getfilestruct zbksh
Getfilestruct zbkshGetfilestruct zbksh
Getfilestruct zbksh
 
Slowinski_Portfolio
Slowinski_PortfolioSlowinski_Portfolio
Slowinski_Portfolio
 
Diplom
DiplomDiplom
Diplom
 
An a z index of the bash commands
An a z index of the bash commandsAn a z index of the bash commands
An a z index of the bash commands
 
Bouncingballs sh
Bouncingballs shBouncingballs sh
Bouncingballs sh
 
Applecmdlista zs
Applecmdlista zsApplecmdlista zs
Applecmdlista zs
 
Stefanie Lopez Angel - PPP Final
Stefanie Lopez Angel - PPP FinalStefanie Lopez Angel - PPP Final
Stefanie Lopez Angel - PPP Final
 
Xz file-format-1.0.4
Xz file-format-1.0.4Xz file-format-1.0.4
Xz file-format-1.0.4
 
An a z index of windows power shell commandss
An a z index of windows power shell commandssAn a z index of windows power shell commandss
An a z index of windows power shell commandss
 
Compound var
Compound varCompound var
Compound var
 
Cuadro sipnotico
Cuadro sipnoticoCuadro sipnotico
Cuadro sipnotico
 
Pcad mision sucre
Pcad mision sucrePcad mision sucre
Pcad mision sucre
 

Semelhante a Mkscript sh

Shell Scripts
Shell ScriptsShell Scripts
Shell Scripts
Dr.Ravi
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
Sudharsan S
 
3output 2.pdf10282017 httpsuml.umassonline.netbbcsw.docx
3output 2.pdf10282017 httpsuml.umassonline.netbbcsw.docx3output 2.pdf10282017 httpsuml.umassonline.netbbcsw.docx
3output 2.pdf10282017 httpsuml.umassonline.netbbcsw.docx
tamicawaysmith
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
Dr.Ravi
 
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaaShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ewout2
 
2-introduction_to_shell_scripting
2-introduction_to_shell_scripting2-introduction_to_shell_scripting
2-introduction_to_shell_scripting
erbipulkumar
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
Raghu nath
 

Semelhante a Mkscript sh (20)

Unix 5 en
Unix 5 enUnix 5 en
Unix 5 en
 
Unix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU KarnatakaUnix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU Karnataka
 
Shell Scripts
Shell ScriptsShell Scripts
Shell Scripts
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
 
Module 03 Programming on Linux
Module 03 Programming on LinuxModule 03 Programming on Linux
Module 03 Programming on Linux
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
3output 2.pdf10282017 httpsuml.umassonline.netbbcsw.docx
3output 2.pdf10282017 httpsuml.umassonline.netbbcsw.docx3output 2.pdf10282017 httpsuml.umassonline.netbbcsw.docx
3output 2.pdf10282017 httpsuml.umassonline.netbbcsw.docx
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
BASH Variables Part 1: Basic Interpolation
BASH Variables Part 1: Basic InterpolationBASH Variables Part 1: Basic Interpolation
BASH Variables Part 1: Basic Interpolation
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming language10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming language
 
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaaShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Mengembalikan data yang terhapus atau rusak pada hardisk menggunakan ubuntu
Mengembalikan data yang terhapus atau rusak pada hardisk menggunakan ubuntuMengembalikan data yang terhapus atau rusak pada hardisk menggunakan ubuntu
Mengembalikan data yang terhapus atau rusak pada hardisk menggunakan ubuntu
 
Unix tips and tricks
Unix tips and tricksUnix tips and tricks
Unix tips and tricks
 
2-introduction_to_shell_scripting
2-introduction_to_shell_scripting2-introduction_to_shell_scripting
2-introduction_to_shell_scripting
 
Bash Scripting Workshop
Bash Scripting WorkshopBash Scripting Workshop
Bash Scripting Workshop
 
Raspberry pi Part 25
Raspberry pi Part 25Raspberry pi Part 25
Raspberry pi Part 25
 
My shell
My shellMy shell
My shell
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
 

Mais de Ben Pope

Programming collaborative-ref
Programming collaborative-refProgramming collaborative-ref
Programming collaborative-ref
Ben Pope
 
Menu func-sh
Menu func-shMenu func-sh
Menu func-sh
Ben Pope
 
Menu func-sh(1)
Menu func-sh(1)Menu func-sh(1)
Menu func-sh(1)
Ben Pope
 

Mais de Ben Pope (8)

Programming collaborative-ref
Programming collaborative-refProgramming collaborative-ref
Programming collaborative-ref
 
Popstat1 sh
Popstat1 shPopstat1 sh
Popstat1 sh
 
Pop3stat sh
Pop3stat shPop3stat sh
Pop3stat sh
 
Phadd sh
Phadd shPhadd sh
Phadd sh
 
Phdel sh
Phdel shPhdel sh
Phdel sh
 
Menu func-sh
Menu func-shMenu func-sh
Menu func-sh
 
Menu func-sh(1)
Menu func-sh(1)Menu func-sh(1)
Menu func-sh(1)
 
Luhn sh
Luhn shLuhn sh
Luhn sh
 

Último

Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usage
Matteo Carbone
 
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabiunwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
Abortion pills in Kuwait Cytotec pills in Kuwait
 
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
lizamodels9
 
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
dollysharma2066
 
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Sheetaleventcompany
 
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
daisycvs
 

Último (20)

Falcon's Invoice Discounting: Your Path to Prosperity
Falcon's Invoice Discounting: Your Path to ProsperityFalcon's Invoice Discounting: Your Path to Prosperity
Falcon's Invoice Discounting: Your Path to Prosperity
 
Phases of Negotiation .pptx
 Phases of Negotiation .pptx Phases of Negotiation .pptx
Phases of Negotiation .pptx
 
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
 
Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usage
 
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxB.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
 
Famous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st CenturyFamous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st Century
 
Cracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptxCracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptx
 
Value Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and painsValue Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and pains
 
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfDr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
 
It will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 MayIt will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 May
 
Call Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine ServiceCall Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine Service
 
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabiunwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
 
Organizational Transformation Lead with Culture
Organizational Transformation Lead with CultureOrganizational Transformation Lead with Culture
Organizational Transformation Lead with Culture
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023
 
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
 
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
 
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
 
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
 
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
 

Mkscript sh

  • 1. #!/bin/bash # /usr/local/bin/mkscript # Copyright 2000, Chris F.A. Johnson # Released under the terms of the GNU General Public License # USAGE: mkscript command # fix permissions for script "command"-sh in /usr/local/bin/scripts # create it if it doesn't exist # link it to "command" in /usr/local/bin die() { exitcode=$1 shift if [ "$*" ] then echo "$*" fi exit ${exitcode:-1} } version() { echo $version } usage() { echo " $progname - USAGE: $progname [OPTIONS] OPTIONS: -d DESC - description -f - force=1 ;; # replace file if it exists -r - remove=1 ;; # remove script if is exists -R - remove=2 ;; # not used -a OPTS - options that take arguments -o OPTS - options that do not take arguments -u - user=$OPTARG ;; -a OPTS - argopts=$OPTARG ;; -h - help: print this message -H - help: print more detailed message -v - verbose: -V - print version information Copyright 2001, Chris F.A. Johnson " } put_header() { echo "#!/bin/bash # `date` # NAME: $command # Copyright `date +%Y`, $author # Released under the terms of the GNU General Public License " } func_die()
  • 2. { echo 'die() { exitcode=$1 shift if [ "$*" ] then echo "$*" fi exit ${exitcode:-1} } ' } func_version() { echo 'version() { echo " $progname, version $version Copyright $copyright, $author $email This is free software, released under the terms of the GNU General Public License. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. " } ' } func_usage() { echo "usage() { echo " $progname - $description USAGE: $progname [OPTIONS] OPTIONS: "" { n=0 while [ $n -lt ${#argopts} ] do l=${argopts:$n:1} echo " -$l arg - " n=$(( $n + 1 )) done n=0 while [ $n -lt ${#opts} ] do l=${opts:$n:1} echo " -$l - " n=$(( $n + 1 )) done } | sort echo " [ $longusage -eq 1 ] && echo " -h - help: print shorter help message -H - help: print this message" || echo " -h - help: print this message
  • 3. -H - help: print more detailed message" echo " -v - verbose: -V - print version information " [ $longusage -eq 1 ] && version || echo " Copyright $copyright, $author " } " } put_vars() { echo " description="$description" verbose=0 longusage=0 version="1.0" copyright=$copyright author="$author"" echo 'progname=${0##*/}' } put_getopts() { [ -n "$argopts" ] && { o=0 while [ $o -lt ${#argopts} ] do l=${argopts:$o:1} [ "$l" ] && getopts="$getopts${NL} $l) ${l}_arg=$OPTARG ;;" optstr=${optstr}${l}: o=$(( $o + 1 )) done } [ -n "$opts" ] && { o=0 while [ $o -lt ${#opts} ] do l=${opts:$o:1} [ "$l" ] && getopts="$getopts${NL} $l) ${l}_opt=1 ;;" optstr=${optstr}${l} o=$(( $o + 1 )) done } echo " while getopts vVhH-:$optstr var do case $var in" echo "$getopts" | sort echo ' -) case $OPTARG in
  • 4. help) usage; exit ;; help_long) longusage=1; usage; exit ;; version) version; exit ;; esac ;; h) usage; exit ;; H) longusage=1; usage; exit ;; v) verbose=$(( $verbose + 1 )) ;; V) version; exit ;; *);; esac done shift $(( $OPTIND - 1 )) ' } bindir="/usr/local/bin" shdir="${bindir}/scripts" version="1.1" verbose=0 force=0 remove=0 longusage=0 progname=${0##*/} NL=$'n' while getopts vVhHfro:a:d:u: var do case "$var" in d) description=$OPTARG ;; f) force=1 ;; # replace file if it exists r) remove=1 ;; R) remove=2 ;; a) argopts=$OPTARG ;; o) opts=$OPTARG ;; u) user=$OPTARG ;; a) argopts=$OPTARG ;; v) verbose=$(( $verbose + 1 )) ;; V) version; exit ;; h) usage; exit ;; H) longusage=1; usage; exit ;; *);; esac done shift $(( $OPTIND - 1 )) echo *=$* echo opts=$opts echo argopts=$argopts if [ ! "$1" ] then die 1 "${progname}: command name required" fi cd ${shdir} command=${1} shcommand=${command}-sh author="`grep -w ^$USER /etc/passwd | cut -d: -f5 | cut -d "," -f1`" copyright=`date +%Y`
  • 5. if [ $remove -ge 1 ] then if [ -f "$shcommand" -a $remove -eq 2 ] then rm -f $shcommand fi if [ -f $bindir/$command ] then rm -f $bindir/$command fi ## add code to remove any other aliases in /usr/local/bin exit fi if [ ! -f $bindir/$command ] then touch $shdir/$shcommand cd $bindir ln -s $shdir/$shcommand $command fi if [ -f "$shcommand" -a $force = 0 ];then echo " $shcommand already exists Use -f to replace it" exit fi ( put_header func_version func_usage put_vars { [ -n "$argopts" ] && { echo $argopts | while read -n1 l do [ "$l" ] && echo "${l}_arg=" done } [ -n "$opts" ] && { echo $opts | while read -n1 l do [ "$l" ] && echo "${l}_opt=0" done } } | sort put_getopts ) > ${shdir}/$shcommand chown ${user:-$USER} ${shdir}/$shcommand chmod a+x ${shdir}/${shcommand} cd $bindir pwd ln -fs scripts/$shcommand $command ls -l ${shdir}/$shcommand
  • 6. if [ $remove -ge 1 ] then if [ -f "$shcommand" -a $remove -eq 2 ] then rm -f $shcommand fi if [ -f $bindir/$command ] then rm -f $bindir/$command fi ## add code to remove any other aliases in /usr/local/bin exit fi if [ ! -f $bindir/$command ] then touch $shdir/$shcommand cd $bindir ln -s $shdir/$shcommand $command fi if [ -f "$shcommand" -a $force = 0 ];then echo " $shcommand already exists Use -f to replace it" exit fi ( put_header func_version func_usage put_vars { [ -n "$argopts" ] && { echo $argopts | while read -n1 l do [ "$l" ] && echo "${l}_arg=" done } [ -n "$opts" ] && { echo $opts | while read -n1 l do [ "$l" ] && echo "${l}_opt=0" done } } | sort put_getopts ) > ${shdir}/$shcommand chown ${user:-$USER} ${shdir}/$shcommand chmod a+x ${shdir}/${shcommand} cd $bindir pwd ln -fs scripts/$shcommand $command ls -l ${shdir}/$shcommand