PDA

View Full Version : Bash & Screensaver questions...


kerang
06-10-2005, 06:08 AM
Hi guys,

I have 2 questions to ask..

(1) Do i need to install bash to the current pcbsd 0.7? if yes, how can i do that over at pcbsd? anyone care to provide the steps?


(2) Secondly, say i activated the screensaver for 5 minutes option and assume i've left my machines and its over 5 minutes and it is suppose to activate the screensaver.. so my question is can the screensaver sort of be locked with password? meaning once i am to the machine and when i move the mouse while the screensaver was running it should prompt out a password box so does this features available in pcbsd 0.7? anyone care to elaborate? thanks...

sblevin
06-10-2005, 06:50 AM
(1) Do i need to install bash to the current pcbsd 0.7

Please remember that bash is not a native in PC-BSD land, so think about learning the other shells that come with FreeBSD first - you will need to become familiar with them anyway if you want to get into scripting.

http://www.freebsd.org/doc/en_US.ISO885 ... hells.html (http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/shells.html)

You can install bash by:
1. Connect to the internet
2: Opening Konsole and su to root
3. Type 'pkg_add -r bash'
This will automatically go out, grab the bash package from a trusted site and install and configure it.

Type 'man bash' to read the manual, and type '/usr/local/bin/bash' to invoke it.

I'll do the screensaver one in a minute : )

Valio
06-10-2005, 06:59 AM
2)Seems that there is a bug in the screensaver thing:

http://www.pcbsd.org/forums/viewtopic.p ... creensaver (http://www.pcbsd.org/forums/viewtopic.php?t=342&highlight=screensaver)

sblevin
06-10-2005, 07:09 AM
Right click on the desktop, select 'Configure Desktop' then select 'Screensaver', then click the 'Help Button' and read away. I can't offer a suggestion as my screensaver dosen't start, the screen just goes black even thought the 'Test' button works.

Put a check in the "Require password to stop' box and set this to 1 second if you don't want a little grace period between the screensaver starting and you having to enter a password to stop it.

kerang
06-10-2005, 07:19 AM
sblevin,
yeah i guess the screensaver should be able to allow users to input password and then when it activates so as when the user is back attending his machine or box when need to access it will prompt for password.. :(

scottro
06-10-2005, 07:31 AM
There is a pbi for bash. So rather than pkg_add you can use the pcbsd package--6 of one, half a dozen of the other. The advantage to the pkg_add is that it will add bash automatically to /etc/shells

The pbi packages doesn't do that and you will have to manually add a line /usr/local/bin/bash to /etc/shells.

Then, to make it your default shell

chsh -s /usr/local/bin/bash


PCBSD uses csh by default. That is the default shell for root in FreeBSD. Many people feel that it is a horrible shell for scripting, but this is a matter of personal taste.

Without writing a book, basically it works this way. FreeBSD's csh is actually tcsh which, like bash has history and tab expansion--that is, if you type part of a file name and hit the tab key, it will complete the name for you or give you a list of possibilities.
The sh shell which is closer to bash, doesn't have tab exansion or history with the arrow keys. These are the two shells that ship with the system and are located in /bin. (This can be handy if, for some reason, you can't mount /usr, which is where other shells installed from ports will be.)

Getting curious about this, I once googled to find out why--apparently, the first developers simply preferred the csh shell to the bourne style shells, therefore, the improved csh was chosen as the more advanced shell to be included with the O/S.

NetBSD has these two (though not sure if their csh is tcsh or not). However, NetBSD also has the korn shell, ksh, which is more similar to bash and other Bourne style shells. As of 2.0, their ksh also has tab expansion and history--prior to that, it didn't have them set automatically.

I have to somewhat disagree with sblevin. Depending upon your needs, you don't need to learn scripting with csh, I would say very few people use it for that.

The sh shell IS often used for scripting. The man reason is that it is portable--that is, if I write a bash or my personal favorite, zsh script, then port it to an AIX box running ksh, it might not work. However, if I write a sh script, then just about ever Unix and Unix clone out there has it.

If you're using GNU/Linux, then it's probably safe to stick with bash, but if you go to a different *nix, then you might have portability problems. For example, sh doesn't have the select loop.

I would install bash and use it for my every day work. I'm more familiar with it than I am with csh, and it's simply more convenient for me to use either bash or zsh.

When you are used to tab completion and history, using sh can be annoying--you hit the tab key and it simply advances however many spaces your tab is set to advance. :) For most things, if, for example, I was in single-user mode and hadn't yet mounted /usr, I would probably use csh, because the FreeBSD version does have tab completion.

For scripting, try to use sh. Sometimes, you need a feature of bash, or another shell, but it will lessen the script's portabilty. Of course we all get into habits. For awhile, I was doing a temperature conversion script with zsh, which handles floating decimals. Bash doesn't.

Then, feeling I would rather use sh, I changed it around--FreeBSD has bc, a math program that handles decimals, as a built in command. However, I then used the program on some Linux distro or another and ran into trouble because they didn't have bc as a builtin command--it had to be installed.

The point being, portability can often be an issue. Many people are used to the Linux seq command. FreeBSD has jot which is similar but not identical.

I think I lost my original point. :) Anyway, install bash--if you use the pbi, then add it to /etc/shells. Make it your default shell as I described. However, as sblevin says (hrrm, may I call you sb?--it's easier to type) you should become at least passingly familiar with the builtin FreeBSD csh and sh. Become familiar enough with csh to use it in emergencies (at the basic level, that is, if you're not scripting, there aren't too many drastic differences) and familiar with sh if you want to write shell scripts.

(As far as sh goes, the differences are basically the things that bash has that sh doesn't, such as the above-mentioned select loop).

kerang
06-10-2005, 08:07 AM
hi scottro,

so i can use the steps whom sblevin has propose on it and it will automatically include the bash into the directory right? so do i still need to amend anything on the default shell script as what you've provided me on the coding? Thanks again... :)

scottro
06-10-2005, 01:28 PM
Correct, follow sblevin's instructions and it should automatically be added to /etc/shells.

Then do the chsh -s thing that I posted and you should be fine.

If you find yourself really getting into FreeBSD though, don't ignore his advice about becoming a bit familiar with the other shells. Learning a shell is a big thing in itself, but just play with the other shells a bit to be sure you could use them in emergencies (I explained why in my VERY long-winded post above).

kerang
06-13-2005, 03:50 AM
hi scottro,
thanks man for the valuable feedback.. :D

zontar
06-13-2005, 10:07 AM
Scottro,

Thanks for the bit about the shells. There's quite a lot of info there, and I don't think I've seen a similar comparison of the common/popular ones before.

helix
02-06-2012, 09:05 PM
I read trough this screensaver topic and have bit different question regarding password for screensaver. Can it be different then user password used for login? I kinda like to have to enter password when i'm away from computer, but I don't care too much for security when concerning "away from keyboard" then I'm keen to have 15char user password. So is there some way to change scr.saver pass to lets say only 3 chars?