Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 30 Sep 2014, 20:42
All times are UTC - 4
 Forum index » House Training » Users ( For the regulars )
The Text-User Interface
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 7 of 8 [110 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, 7, 8 Next
Author Message
Bruce B


Joined: 18 May 2005
Posts: 11109
Location: The Peoples Republic of California

PostPosted: Sat 29 Aug 2009, 02:20    Post subject:  

Chapter 92 - a script wanted

Script wanted:

Friends, I've tested the 'proof of concept', the file I'm wanting is easy to make. I'm hoping the readers have been programming and can do this assignment. If you want to work on it, but are embarrassed or not confident, PM me and I'll post it synonymously.

Filenane: checkdiff

Description: using the find command it searches the /parent directories and makes a text database of all files, symlinks and directories in a /parent directory. e.g. /usr and /root

We want to learn about changes in the directory from time to time. We use the find command a second time, merge the two files and pipe the test file to sort | uniq -u.

uniq only works right on a list of sorted files, the uniq -u swich will print only the differences.

Thus we can get a report on files which have been added or deleted.

Fun practical and I have an even more useful similar utility up my sleeve, but I want to see how we do on this.

~

Chapter 92 - a script wanted

_________________
New! Puppy Linux Links Page
Back to top
View user's profile Send private message 
Bruce B


Joined: 18 May 2005
Posts: 11109
Location: The Peoples Republic of California

PostPosted: Wed 02 Sep 2009, 18:46    Post subject:  

Chapter 93 assignment submitted

I'm pleased to present anonymously submitted work from chapter 92.

First version

Code:
#!/bin/bash
cd /usr/
# check if a list exists: if not create one and exit.
if
[ ! -e usr-list.cd ]
then echo "Nothing to compare. Creating 'usr-list' then exiting"
find -maxdepth 1 > usr-list.cd && exit
fi

find -maxdepth 1 > usr-list-new.cd
cat usr-list.cd usr-list-new.cd > joined.cd
sort joined.cd | uniq -u
# get rid of the temporary files
rm -f *.cd

exit


Second version

Code:
#!/bin/bash
# Just realised my basic error
if
[ ! -e list ]
then echo "Nothing to compare. Creating 'list' then exiting"
find -maxdepth 1 > list && exit
fi

find -maxdepth 1 > list-new.cd
cat list list-new.cd > joined.cd
sort joined.cd | uniq -u
rm -f *.cd
exit


Third version
Code:
#!/bin/bash
# I think I've finally got something a little more sensible:
if
[ ! -e /root/list ]
then echo "Nothing to compare. Creating 'list' then exiting"
find -maxdepth 1 > /root/list && exit
fi

find -maxdepth 1 > /root/list-new
cat /root/list /root/list-new > /root/joined
sort /root/joined | uniq -u
exit

# I just put the temporary files in root, out of the way,
# and they get overwritten anyway - so no need for 'rm' really.


Comment: Thanks for the submission. This is exactly how I learn. I write some code. Then, maybe the next day, I conceive a better way or notice a flaw, then refine or even rewrite the code.

In the beginning stages some can learn by lectures, examples and theory. As for me I need to 'code' to develop the skill and confidence.

Thanks again

~

Chapter 93 assignment submitted

_________________
New! Puppy Linux Links Page
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4351

PostPosted: Mon 04 Jan 2010, 01:54    Post subject:  

Simple ldd script to find dependencies - should work on any *nix

Code:
#!/bin/sh
if [ -x $1 ]; then
/lib/ld-linux.so.2 --list $1
else
 if [ -x `which $1` ]; then
 /lib/ld-linux.so.2 --list `which $1`
 else
 echo Can't find it. Try using full path.
 fi
fi


(This one has the comments remove - only 98bytes)

#!/bin/sh
if [ -x $1 ]; then /lib/ld-lsb.so.1 --list $1
else
/lib/ld-lsb.so.1 --list `which $1`
fi

(this one requires the full path - 37 bytes)

#!/bin/sh
/lib/ld-lsb.so.1 --list $1

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
01micko


Joined: 11 Oct 2008
Posts: 7805
Location: qld

PostPosted: Fri 02 Jul 2010, 01:22    Post subject:  

hehe

simple word/string finder

Inspired by techno Wink In living colour Laughing

EDIT: Well I posted this in a separate thread and am maintaining it, the code has progressed from what is below. It mainly demonstrates the use of colours in the CLI. Enjoy! SCLISS

Code:
#!/bin/sh
#01micko (01micko@gmail.com) GPL 2010
#simple command line search script
#syntax "scliss -w" for a word
#"scliss -s" for a string
#"scliss -h" help
#"scliss -v" version
#if you want to colour your bash I got it from "http://edoceo.com/liber/linux-bash-shell"
VER="0.1"
DIR=$2
if [ "$DIR" != "" ];then cd $DIR 2>/dev/null
fi
if [ "$DIR" = "/tmp" ];then
   echo -en "\033[0;35m""Er sorry.. haven't figured out how to handle /tmp yet"  #magenta text
   echo -e "\033[0m"
   exit
fi
if [[ $? -ne 0 ]];then
   echo -en "\033[0;31m""Woops! That's not a directory!"  #red text
   echo -e "\033[0m"
   exit
fi
case $1 in
-w)   echo "type one word you are searching for"
   read SEARCH
   grep $SEARCH *
   ;;
-s)   echo "type a string you are searching for"
   read STRING
   grep "${STRING}" *
   ;;
-h)   echo "You have invoked scliss help"
   echo "Options"
   echo "   -h prints this help and exits"
   echo ""
   echo "   -v prints version and exits"
   echo ""   
   echo "   -w) type a word to search for in the current directory"
   echo "   and the line(s) where that word resides will be returned for"
   echo "   every instance it occurs in a line"
   echo "   SYNTAX: scliss -w [/path/to/dir]"
   echo ""
   echo "   -s) type a string to search for in the current directory"
   echo "   and the line(s) where that string resides will be returned for"
   echo "   every instance it occurs in a line"
   echo "   SYNTAX: scliss -s [/path/to/dir]"
   echo ""
   echo -en "\033[1;33;45m""   the \"/path/to/dir\" is optional"  #yellow text bright, magenta background
   echo -e "\033[0m"
   echo "============================================================"   
   echo -en "\033[0;34m""01micko@gmail.com GPL 2010 NO WARRANTY" #blue text
   echo -e "\033[0m"
   exit
   ;;
-v) echo "scliss-${VER}"
   exit
   ;;
*)   echo "ERROR: You need an option. Type \"scliss -h\" for more"
   exit
   ;;
esac
   if [[ $? -ne 0 ]];then
   echo -en "\033[0;31m""Boo! Not found"  #red text
   echo -e "\033[0m"
   exit
      else echo -en "\033[0;32m""There you go, found it!"  #green text
      echo -e "\033[0m"
      exit
   fi


Cheers

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send private message Visit poster's website 
Bruce B


Joined: 18 May 2005
Posts: 11109
Location: The Peoples Republic of California

PostPosted: Fri 09 Jul 2010, 15:12    Post subject:  

Very good!

Years ago I made simple color changing C source code to use in DOS batch programming.

The basic idea is: it was easier to type in the first three characters of a color than calling a batch file or running the full escape sequence.

If I want text to change to magenta, I enter the command 'mag' then when I want to change the text output again, I enter another color command.

The command itself doesn't insert a line break or change cursor position, it just makes to the text after the command the color I want.

I'm pasting a picture of the C source rather than posting the code as text, because the escape character usually doesn't transfer.

I think it would be very easy to make Linux code by using its escape and color sequences and the printf function.

If you are interested in the project and sharing your work :)
magenta.jpg
 Description   
 Filesize   15.59 KB
 Viewed   4746 Time(s)

magenta.jpg


_________________
New! Puppy Linux Links Page
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4351

PostPosted: Sat 10 Jul 2010, 23:16    Post subject:  

Here is one for all the fans of Big Bang Theory, a modified version of Dr. Sheldon Cooper's "Friendship Algorithm" adapted as a bash script.

Code:
#!/bin/sh
person=$1

_partake_(){
   INTERESTS=`Xdialog --stdout --3inputsbox 'Ask '$person' "What are your interests?"' 0 0 "Interest #1" "" "Interest #2" "" "Interest #3" "" |sed "s/\// 0 0 /g" `
   Xdialog --stdout --no-tags --radiolist 'Ask '$person' "What is the least objectionable interest"' 0 0 0 0 $INTERESTS 0
   Xdialog --msgbox "Partake in "$?"." 0 0
   }

_drink_(){
   Xdialog --yesno 'Ask '$person' "Do you enjoy a hot beverage?"' 0 0
   [ $? != 1 ] && BEVERAGE=`Xdialog --stdout --no-tags --radiolist "Which beverage?" 0 0 0 Coffee Coffee 0 Tea Tea 0 \Cocoa Cocoa 0` && Xdialog --msgbox "Have "$BEVERAGE" together" 0 0 || _partake_
#____________________________________________________
   
_dine_(){
Xdialog --stdout --yesno "Place a phone call to "$person".
Did "$person" answer?" 0 0
[ $? == 1 ] && Xdialog --msgbox "Leave "$person" a message and wait for a call back" 0 0
Xdialog  --stdout --yesno 'Ask '$person', "Would you like to share a meal?"' 0 0
[ $? != 1 ] && Xdialog --msgbox "Dine with $person" 0 0 || _drink_
}

_dine_ #? or _drink_ or _partake_ in interest

#....Sheldon says this begins the friendship, but I prefer to do a worthiness evaluation
Xdialog --stdout --yesno "Is "$person" worthy?" 0 0
[ $? == 0 ] && Xdialog --msgbox "Congratulations, "$person" is now your friend" 0 0 && exit
$0 `Xdialog --stdout --inputbox "Unfortunately "$person" is not going to work out as a friend,
Enter the name of another person you would like to be friends with." 0 0`

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
plankenstein


Joined: 15 Nov 2008
Posts: 121
Location: Arkansas, USA

PostPosted: Sun 11 Jul 2010, 03:03    Post subject: bash 4.0.10  

First off let me say this is a great tutorial. Just happened across it and am loving it. But, on the first page you talked about loading a newer version of bash, but the file has been removed. Do you have any plans to put this bash.zip back up or is there some place else I might find it? So far, I'm doing okay following along with the 3.00.16 that came with Dpup, but would like to see how the newer one compares.

Thanks for the hard work that obviously went into this. I've already picked up some new skills and I'm just on chapter 7. This is going to keep me entertained for quite some time to come. Very Happy

_________________
I carefully plan ALL my random acts! Laughing
Back to top
View user's profile Send private message 
01micko


Joined: 11 Oct 2008
Posts: 7805
Location: qld

PostPosted: Mon 12 Jul 2010, 17:03    Post subject:  

Bruce B wrote:
Very good!

Years ago I made simple color changing C source code to use in DOS batch programming.

The basic idea is: it was easier to type in the first three characters of a color than calling a batch file or running the full escape sequence.

If I want text to change to magenta, I enter the command 'mag' then when I want to change the text output again, I enter another color command.

The command itself doesn't insert a line break or change cursor position, it just makes to the text after the command the color I want.

I'm pasting a picture of the C source rather than posting the code as text, because the escape character usually doesn't transfer.

I think it would be very easy to make Linux code by using its escape and color sequences and the printf function.

If you are interested in the project and sharing your work Smile


Thanks for the compliment Bruce.

Actually I had already implemented something similar in the latest SCLISS revision. It now reads a config file and any script can actually read that file.
I will post a snippet, its way too large to put it all in one post, but I'll attach the full file. I put it in /etc, which as I understand is a usual place for system
wide settings. I could have made it a hidden file in $HOME too I guess.

Code:
#colors #put together for Puppylinux by 01micko, GPL 2010
#RESULTS MAY NOT be exactly as expected... NO WARRANTY
#Basics
#usual thing is style, fg, bg
#invoke with: echo -en "$COLOR""the text you want" ...where color will be something from the table below (-n is optional)
#stop with: echo -e "$CLEAR_TEXT"
#clear text. This resets the terminal after you have used the colors #ESSENTIAL
CLEAR_TEXT="\033[0m"
#basics
BLACK="\033[0;30m"
RED="\033[0;31m"
GREEN="\033[0;32m"
YELLOW="\033[0;33m"
BLUE="\033[0;34m"
MAGENTA="\033[0;35m"
CYAN="\033[0;36m"
WHITE="\033[0;37m"
#BOLD
BLACK_B="\033[1;30m"
RED_B="\033[1;31m"
GREEN_B="\033[1;32m"
YELLOW_B="\033[1;33m"
BLUE_B="\033[1;34m"
MAGENTA_B="\033[1;35m"
CYAN_B="\033[1;36m"
WHITE_B="\033[1;37m"
#italics
BLACK_I="\033[3;30m"
RED_I="\033[3;31m"
GREEN_I="\033[3;32m"
YELLOW_I="\033[3;33m"
BLUE_I="\033[3;34m"
MAGENTA_I="\033[3;35m"
CYAN_I="\033[3;36m"
WHITE_I="\033[3;37m"
#underline
BLACK_U="\033[4;30m"
RED_U="\033[4;31m"
GREEN_U="\033[4;32m"
YELLOW_U="\033[4;33m"
BLUE_U="\033[4;34m"
MAGENTA_U="\033[4;35m"
CYAN_U="\033[4;36m"
WHITE_U="\033[4;37m"
#COLORED BACKGROUNDS
#WHITE   #GOOD FOR BLACK TERMINAL
BLACK_WBG="\033[0;30;47m"
RED_WBG="\033[0;31;47m"
GREEN_WBG="\033[0;32;47m"
YELLOW_WBG="\033[0;33;47m"
BLUE_WBG="\033[0;34;47m"
MAGENTA_WBG="\033[0;35;47m"
CYAN_WBG="\033[0;36;47m"
WHITE_WBG="\033[0;37;47m"
#(SNIP) see attachment


It also deals with bold, italics and underline as well as coloured backgrounds. I think I covered the lot, well enough anyway!

Cheers
bash_colors.rc.gz
Description 
gz

 Download 
Filename  bash_colors.rc.gz 
Filesize  1.71 KB 
Downloaded  1089 Time(s) 

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send private message Visit poster's website 
technosaurus


Joined: 18 May 2008
Posts: 4351

PostPosted: Thu 15 Jul 2010, 22:57    Post subject:  

Code:
#!/bin/sh
echo Direct Dependencies: && objdump -x $1 |grep NEEDED |sed "s/NEEDED//g" |sed "s/ //g"


I call this one lddd because it only lists the direct dependencies

For instance: if you link against X11, regular ldd will also list libXau, libxdmcp and others because they are a dependency of X11

this may only be useful for someone building a small/embedded distro around proprietary software like skype, opera and flashplugin etc... but maybe other uses?

this can tell you if it is possible to statically link a dependent library directly into the shared library that is actually linked against ... or maybe even configure the shared library that is linked against without the unused libs if possible - you'd be surprised how many are really unnecessary

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
Frank Cox

Joined: 01 Nov 2009
Posts: 381

PostPosted: Fri 13 Aug 2010, 02:25    Post subject: .gz  

could you tell me the commands if the bash comes as a tar.gz.gz?
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4351

PostPosted: Fri 13 Aug 2010, 09:06    Post subject:  

gunzip *
gunzip *
tar -xf *

(you probably don't need the 2nd gunzip)

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4351

PostPosted: Sun 22 Aug 2010, 16:16    Post subject:  

Here is a little script I wrote to download and allow older versions of flash to work on websites that require a newer version unnecessarily (by faking the version number)
Flash7 will work on non-gtk2 browsers
Flash9 is smaller, has much fewer dependencies (no mozilla libs) and is still being updated (for enterprise linux distros)
Flash10.X default is to install the latest version in case of a site that actually requires features that are only in 10.x.
Code:
#!/bin/sh
case $1 in
--help)echo "options are:
7 for smallest size and dependencies,
9 for medium size and fewer dependencies
  for latest version leave options blank"
;;

#download all flash7 & fake latest as 10.1 r9
7)wget -c http://fpdownload.macromedia.com/get/flashplayer/installers/archive/fp7_archive.zip
unzip fp7_archive.zip
tar -xf fp7_archive/r73/install_flash_player_7_linux_r73.tar.gz
cat install_flash_player_7_linux/libflashplayer.so |sed -e "s/7.0 r73/10.1 r9/g" >/usr/lib/mozilla/plugins/libflashplayer.so
rm -rf fp7_archive.zip install_flash_player_7_linux_r73.tar.gz install_flash_player_7_linux fp7_archive
yaf-splash -text "flash7 installed as flash10.1" -transparent -bg red -timeout 10
;;

#download latest flash9 & fake install as 10.1 r99
9)wget -c http://download.macromedia.com/pub/flashplayer/installers/current/9/install_flash_player_9.tar.gz
tar -xf install_flash_player_9.tar.gz
VER=`strings libflashplayer.so | grep -e "^Shockwave Flash [.\d+]*" | sed -e "s/Shockwave Flash //g"`
cat libflashplayer.so |sed -e "s/$VER/10.1 r99/g" >/usr/lib/mozilla/plugins/libflashplayer.so
rm -f libflashplayer.so install_flash_player_9.tar.gz
yaf-splash -text "flash9 installed as flash10.1" -transparent -bg red -timeout 10
;;

#download and install latest flash
*)wget -c http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player_10_linux.tar.gz
tar -xf install_flash_player_10_linux.tar.gz
mv -f libflashplayer.so /usr/lib/mozilla/plugins/libflashplayer.so
rm -f install_flash_player_10_linux.tar.gz
yaf-splash -text "latest flash installed" -transparent -bg red -timeout 10
;;
esac
exit

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
ds2dys

Joined: 11 Sep 2010
Posts: 14
Location: Ontario, Canada

PostPosted: Tue 28 Sep 2010, 12:57    Post subject:  

Wow! Shocked

This was my only word came out from my mouth when I clicked through page numbers to find over 90 chapters.
This is amazing lecture for people who want to learn about Linux like me. I'm going to start from the Chapter 1 now.

Thank you very much for sharing this valuable knowledge.

Very Happy Very Happy Very Happy
Back to top
View user's profile Send private message 
eriksatie

Joined: 06 Jun 2011
Posts: 41

PostPosted: Tue 07 Jun 2011, 04:51    Post subject:  

ds2dys wrote:
Wow! Shocked

This was my only word came out from my mouth when I clicked through page numbers to find over 90 chapters.
This is amazing lecture for people who want to learn about Linux like me. I'm going to start from the Chapter 1 now.

Thank you very much for sharing this valuable knowledge.

Very Happy Very Happy Very Happy


I would like to second this notion. I'm still on the first page, but I will be making my way to the rest of the chapters in due time.

Thank you so much for taking the time to teach us linux newbies the TUI!

Cool
Back to top
View user's profile Send private message 
Superdooper

Joined: 28 Aug 2011
Posts: 4

PostPosted: Sat 03 Sep 2011, 17:49    Post subject: Thanks  

Thanks for the tutorial! Wow im amazed some one took the time to write this up. Hopefully you will get the time to continue the series. Thanks again! Very Happy
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 7 of 8 [110 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, 7, 8 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Users ( For the regulars )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1270s ][ Queries: 13 (0.0069s) ][ GZIP on ]