SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
-z is for testing empty strings.................in this case, the test is for NOT an empty string [ ! -z ... ], and by using the 'for' statement, it breaks up the input from the 'cat' command whenever 'for' parses any whitespace (blank spaces, tabs) or newlines, thereby letting you test each space-delimited field separately..........
cat << "__EOF__" > /usr/local/bin/chngcd && chmod 755 /usr/local/bin/chngcd
#!/bin/sh
#*******************************************************************************
# Name: chngcd
# Mount point for CDROM device
CDROM=/mnt/cdrom
umount -l $CDROM 2> /dev/null
eject $CDROM
echo -en "\n After replacing or removing the CD, simply press [Enter]..." \
&& read ans && echo
mount $CDROM 2> /dev/null
__EOF__
It doesn't work because the mount, umount and eject commands are available only for the root user. I prefer sudoing it:
/usr/local/bin/cdrom:
### beginning ###
case "$1" in
'mount')
sudo /sbin/mount /mnt/cdrom/ ;;
'umount')
sudo /sbin/umount /mnt/cdrom/ ;;
*)
echo "Usage $0 mount|umount" ;;
esac
### end ###
And following in my
/etc/sudoers
##begin##
ivanatora ALL=NOPASSWD: /sbin/mount /mnt/cdrom/,/sbin/umount /mnt/cdrom/
##end##
Of course 'ivanatora' is my username, so if you want this to work you should change this. It can be easily modified to eject the cdrom, but I can't see the point.
Originally posted by ivanatora It doesn't work because the mount, umount and eject commands are available only for the root user...
Not on my machine...............those commands are in bin directories, not sbin directories................if you have problems, then it's probably a matter of how you're permissions are set for the CDROM device.............usually, the CDROM is set for anyone to mount and unmount..............otherwise CDROMs wouldn't be very useful for users..................
If anyone is having problems, there are two ways to overcome it....................either add the user to the same group as the block device ("disk" for Slackware), or change the permissions on the block device to make it readable for "others", ie., brw-r--r--
If you add the user to the same group as the block device for the CDROM, you might have to logout completely or reboot the machine...............
Here is a useful, if totally simplistic script, that is handy to see what Slackware packages in a given directory are *not* installed. For instance, I keep a local mirror of Slackware-current and I want to know if there are any packages in my slackware-current/slackware/gnome directory that are not already installed. I put a copy of this script in /usr/local/bin and change to /home/ftp/pub/slackware-current/slackware/gnome and run packcheck.sh. If anybody wants to improve on this, post your improvements here.
--------------------
#!/bin/sh
for pack in $(ls *.tgz); do
pack=$(basename $pack .tgz)
if [ ! -f /var/log/packages/$pack ]; then
echo "No Package $pack found"
fi
done
------------------
*** FINAL UPDATES for lspkg, whichpkg, and pkginfo ***
Okay, I think I've gone about as far as I can with these three scripts, lspkg, whichpkg, and pkginfo................They are all converted over from using regular expression syntax to wildcard matching (globbing). While not true globbing, they are close enough for practical purposes here...........If you're interested knowing what the difference is, read the manpages for globbing and regular expressions, 'man 7 glob' and 'man 7 regexp'. (Note - For KDE users, you can view the manpages in a html format by entering these urls in Konqueror, 'man:/glob(7)' and 'man:/regexp(7)'. This only works in Konqueror, not any other browser in KDE.).......Be sure to include the number 7 in both............
I did a major overhaul for the whichpkg script, making it easier to read the output, filtering out more of the unwanted garbage, and allowing for multiple search terms. It ended up being a bit of a challenge, more than I had anticipated....... ..........but I think I've got it right (it sure did sharpen my regexp skills.......LOL).............A few search terms were quite unpredictable, most notably the searches for "ln", "file", "install" and "sh"...........If there are others you come across which seem not quite right, be sure to post them here and I'll fix it. otherwise this is pretty much the final update.
The other two were mostly to convert to using wildcard searching (pkginfo) or a minor change in the usage of the wildcards in the search term (lspkg)..........Again, I don't see where they can go much farther, so these will also be the final updates.
HOWEVER................I'm going to create another Slackware specific script to deal with orphaned files by looking at all the system files and matching them against the list of files found in the /var/log/packages/ and /var/log/scripts/ directories..............Then you will be presented with a report of all the files that aren't accounted for from the installed packages..............Some of these may be from various scripts and files you may have added manually, such as these scripts, but some may be leftovers from old installations no longer around.................Either way, you will have a list to look over and decide for yourself whether they belong there or not..............The reason for this script is from some of the posts I've seen recently asking about what files are safe to remove, or a way to determine which files are not wanted or needed...........I do love a challenge.............
Okay, enought talk, the changes have already been made in the top post (post #1) above....
EDIT: Changed line number 53 in "pkginfo" script by removing the path "/var/log/packages/" (The third line from the end, above the two "esac" lines). Thanks goes to carboncopy for pointing out this error.
EDIT2: More changes needed in the "pkginfo" script as noted below.
Last edited by thegeekster; 07-08-2004 at 02:44 PM.
Hi! I tested out all three new one but pkginfo seems to be not working properly for me. This is what happens:
Code:
bash-2.05b# ./pkginfo gnome
-------------------------------------------------------------------------------
More than one package was found matching the name, "gnome".
Choose a package from the following list (Hint: Use the mouse to copy-n-paste
the desired package name)...
-------------------------------------------------------------------------------
/var/log/packages/gnome-applets-2.6.1-i486-1
/var/log/packages/gnome-audio-2.0.0-noarch-1
/var/log/packages/gnome-desktop-2.6.2-i486-1
/var/log/packages/gnome-games-2.6.1-i486-3
/var/log/packages/gnome-icon-theme-1.2.3-noarch-1
/var/log/packages/gnome-keyring-0.2.1-i486-1
/var/log/packages/gnome-media-2.6.2-i486-1
/var/log/packages/gnome-mime-data-2.4.1-noarch-1
/var/log/packages/gnome-netstatus-2.6.1-i486-1
/var/log/packages/gnome-panel-2.6.2-i486-1
/var/log/packages/gnome-session-2.6.2-i486-1
/var/log/packages/gnome-speech-0.3.3-i486-1
/var/log/packages/gnome-system-monitor-2.6.0-i486-1
/var/log/packages/gnome-terminal-2.6.1-i486-1
/var/log/packages/gnome-themes-2.6.2-i486-1
/var/log/packages/gnome-themes-extras-0.7-i486-1
/var/log/packages/gnome-utils-2.6.2-i486-1
/var/log/packages/gnome-vfs-2.6.1.1-i486-2
/var/log/packages/libgail-gnome-1.0.4-i486-1
-------------------------------------------------------------------------------
Enter package name here: gnome-audio
cat: /var/log/packages//var/log/packages/gnome-audio-2.0.0-noarch-1: No such file or directory
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.