I am sometimes required to write PHP scripts and I find typing tags and comments quite boring. Look what I have done. I have written a fully automated script that will make you job very easy and you can easily place tags and comments into your php scripts.
Just go through it and let me know if you happen to come across any bug in it. eMail me at paragkalra@gmail.com
#!/bin/bash
#Author: Parag Kalra
#Date: 14th June, 2008
#Name: php-tags.sh
#Usage: ./php-tags.sh
#Purpose: To automatically add comments and html tags.
# BEGINNING
echo "Enter the name of the shell script: "
read SHNAME
echo "Enter the purpose of this shell script: "
read SHPURPOSE
export SHDATE #='$SHDATE'
export SHNAME #='$SHNAME'
export SHPURPOSE #='$SHPURPOSE'
touch $SHNAME
echo "html tag" >> $SHNAME
echo "head tag, title tag, title end tag, head end title>" >> $SHNAME
echo "body tag" >> $SHNAME
echo "php start tag" >> $SHNAME
echo "#!/bin/bash" >> $SHNAME
echo "#Author: Parag Kalra" >> $SHNAME
echo "#Date: $SHDATE" >> $SHNAME
echo "#Name: $SHNAME" >> $SHNAME
echo "#Usage: ./$SHNAME" >> $SHNAME
echo "#Purpose: $SHPURPOSE" >> $SHNAME
echo "php end tag" >> $SHNAME
echo "body end tag" >> $SHNAME
echo "html end tag" >> $SHNAME
#END OF SCRIPT
Saturday, June 14, 2008
Monday, June 2, 2008
Functions in Shell-Scripting => Part 1
#!/bin/bash
#Author: Parag Kalra
#Date: 3rd June, 2008
#Name: func1.sh
#Usage: ./func1.sh
#Purpose: To illustrate usage of functions in Shell Scripts.
JUST_A_SECOND=1
REPEATS=3
funky()
{
echo "This is a just funky function...not that exciting..."
}
fun()
{
echo "The real fun starts now."
i=0
sleep $JUST_A_SECOND
while [ $i -lt $REPEATS ]
do
echo "FUNCTIONS R FUN"
echo
let "i+=1"
done
}
funky
fun
The output of above script is:
This is a just funky function...not that exciting...
The real fun starts now.
FUNCTIONS R FUN
FUNCTIONS R FUN
FUNCTIONS R FUN
Just go through it and let me know if you happen to come across any bug in it. eMail me at paragkalra@gmail.com
#Author: Parag Kalra
#Date: 3rd June, 2008
#Name: func1.sh
#Usage: ./func1.sh
#Purpose: To illustrate usage of functions in Shell Scripts.
JUST_A_SECOND=1
REPEATS=3
funky()
{
echo "This is a just funky function...not that exciting..."
}
fun()
{
echo "The real fun starts now."
i=0
sleep $JUST_A_SECOND
while [ $i -lt $REPEATS ]
do
echo "FUNCTIONS R FUN"
echo
let "i+=1"
done
}
funky
fun
The output of above script is:
This is a just funky function...not that exciting...
The real fun starts now.
FUNCTIONS R FUN
FUNCTIONS R FUN
FUNCTIONS R FUN
Just go through it and let me know if you happen to come across any bug in it. eMail me at paragkalra@gmail.com
Sunday, June 1, 2008
Concept of Sub-Shells - Part 2
Variables defined in a subshell are "local variables. Also variable operations inside a subshell, even to a GLOBAL variable do not affect the value of the variable outside the subshell! Kindly refer to the script given below:
#!/bin/bash
#Author: Parag Kalra
#Date: 1st June, 2008
#Name: glo-var-sub-shell.sh
#Usage: ./glo-var-sub-shell.sh
#Purpose: To illustrate concept of global variables within sub-shells
global_variable=
outer_num=12
echo "Outside Subshell"
echo "global_variable=$global_variable"
echo "outer_num=$outer_num "
echo " "
(
echo "Inside Subshell"
inner_variable=26
let "outer_num+=1"
echo "global_variable=$global_variable"
echo "outer_num=$outer_num"
echo "inner_variable=$inner_variable "
echo " "
)
echo "Again Outside of Subshell"
echo "outer_num=$outer_num"
echo "inner_variable=$inner_variable"
# END OF SCRIPT
The output of above script is:
Outside Subshell
global_variable=
outer_num=12
Inside Subshell
global_variable=
outer_num=13
inner_variable=26
Again Outside of Subshell
outer_num=12
inner_variable=
Just go through it and let me know if you happen to come across any bug in it. eMail me at paragkalra@gmail.com
#!/bin/bash
#Author: Parag Kalra
#Date: 1st June, 2008
#Name: glo-var-sub-shell.sh
#Usage: ./glo-var-sub-shell.sh
#Purpose: To illustrate concept of global variables within sub-shells
global_variable=
outer_num=12
echo "Outside Subshell"
echo "global_variable=$global_variable"
echo "outer_num=$outer_num "
echo " "
(
echo "Inside Subshell"
inner_variable=26
let "outer_num+=1"
echo "global_variable=$global_variable"
echo "outer_num=$outer_num"
echo "inner_variable=$inner_variable "
echo " "
)
echo "Again Outside of Subshell"
echo "outer_num=$outer_num"
echo "inner_variable=$inner_variable"
# END OF SCRIPT
The output of above script is:
Outside Subshell
global_variable=
outer_num=12
Inside Subshell
global_variable=
outer_num=13
inner_variable=26
Again Outside of Subshell
outer_num=12
inner_variable=
Just go through it and let me know if you happen to come across any bug in it. eMail me at paragkalra@gmail.com
Subscribe to:
Comments (Atom)
