With fresh 9.1 install, bash completion no longer expands $HOME

2013-06-10 Thread David P. Caldwell
On my 9.0-based machines, if I typed $HOME[tab] when typing a command
in bash, the $HOME would be overwritten by the actual path to my home
directory (the value of $HOME) and tab completion would work as
expected.

After a fresh 9.1 install, this does not work as well.

$HOME is still detected by completion, but it is not expanded after
pressing tab (this does not matter to me), but also an extra space is
inserted after tab.

For example, if I have a directory named src under my home directory,
and my working directory is an unrelated directory, and I type cd
$HOME/sr[tab]:

Under 9.0:
cd /home/dcaldwell/src/[cursor]

Under 9.1:
cd $HOME/src [cursor]

So under 9.1 I lose the slash and see a space instead, essentially,
which renders this not very useful.

If I use ~ rather than $HOME, it works correctly under both. Obviously
I could probably learn to type ~ rather than $HOME but it would be a
hard habit to break after years. :)

For bash (and for most software) I am using binary packages from the
-release distribution, so my 9.0 machines have 4.1.11 and my 9.1
machines have 4.2.37.

I don't know enough about all the moving parts to know where to start
tracking this down, so can someone point me in the right direction?
(Unless there's an known problem or change I'm missing.) I can't
figure out where completion is configured in bash outside the
/usr/local/etc/bash_completion.d/ directory, which incidentally on my
9.1 setup contains:

$ ls /usr/local/etc/bash_completion.d/
dbus-bash-completion.sh*gdbus-bash-completion.sh*
gsettings-bash-completion.sh*

Thanks,

-- David Caldwell
http://www.davidpcaldwell.com/
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: With fresh 9.1 install, bash completion no longer expands $HOME

2013-06-10 Thread Jeremy Chadwick
Re: http://lists.freebsd.org/pipermail/freebsd-questions/2013-June/251607.html

This has nothing to do with FreeBSD 9.0 vs. 9.1 other than the fact that
the package on 9.0 is older than 9.1.  Instead, this has everything to
do with the difference between bash versions you're using.  Remember:
packages and ports 99% of the time are third-party software (in this
case GNU), and therefore any changes in behaviour between versions are
entirely independent of FreeBSD.

The feature you like from bash 4.1 was removed in some manner of
speaking in bash 4.2.  This prompted a user to complain -- please read
the thread (not just the post) in full, because you will see there are
others who *do not* like this behaviour:

http://lists.gnu.org/archive/html/bug-bash/2011-02/msg00274.html

In bash 4.2.29 -- which is technically patch 029 for bash 4.2 -- the
feature you desire got moved into a shopt feature called direxpand,
with the default being disabled.  Because bash 4.3 is not out yet, you
will not find any mention of this in the official bash CHANGES file at
this time.  Instead, you will find the answer in the official bash42-029
patch itself (read the top):

ftp://ftp.gnu.org/gnu/bash/bash-4.2-patches/bash42-029

If you do not like this default, or feel strongly about this whole thing
and want to discuss it, the GNU bug-bash mailing list is the place:

http://www.gnu.org/software/bash/

To enable direxpand, use shopt -s direxpand.  You can put this command
in your ~/.bashrc.

-- 
| Jeremy Chadwick   j...@koitsu.org |
| UNIX Systems Administratorhttp://jdc.koitsu.org/ |
| Making life hard for others since 1977. PGP 4BD6C0CB |

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Bash history empty on login

2013-01-08 Thread Dimitri Yioulos
On Monday 07 January 2013 7:01:09 pm Andre Goree wrote:
 I'm not sure what's going on, as I've never had an issue
 like this in my years of using FreeBSD nor Linux.  Each
 time I login, my history file is empty!  I'm not sure
 what could be causing this, but below [1] is my .bashrc. 
 I had . ~/.bashrc in ~/.profile, but I removed it while
 I'm trying to troubleshoot this issue.  Does anyone have
 an idea or a direction to point me in?  Thanks in
 advance.

 [1]#
 # ~/.bashrc
 #

 # If not running interactively, don't do anything
 [[ $- != *i* ]]  return

 #PS1='[\u@\h \W]\$ '

 alias ls='ls -G'
 alias ll='ls -lAhp'
 alias umount='sudo umount'
 alias grep='grep --color'
 alias nmap='sudo nmap'
 alias updatedb='sudo updatedb'
 alias pkg_add='sudo pkg_add'
 alias pkg_delete='sudo pkg_delete'
 alias top='top -aPStzj -s 1'
 alias portinstall='sudo portinstall'
 alias updatedb='sudo updatedb'

 PS1='\[\e[1;37m\][\u@\h \W]\$\[\e[0m\] '

 export PATH=$PATH:/home/agoree/bin:/usr/local/kde4/bin/

 #BASH history
 export HISTTIMEFORMAT=%h/%d - %H:%M:%S 
 export HISTFILESIZE=10
 #export VBOX_USB=usbfs

 --

Hope I'm not offending you if the following are things 
you've tried as a matter-of-course:

After booting up, is history started, or do you have to do 
that manually?  Have you run set -o to see if history is 
enabled?  If it isn't, then set -o history.  Is a clear 
command being issued from anywhere upon logout or reboot?

Just some thoughts.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Bash history empty on login

2013-01-08 Thread Andre Goree
On Tue, 08 Jan 2013 07:59:51 -0500, Dimitri Yioulos  
dyiou...@onpointfc.com wrote:




Hope I'm not offending you if the following are things
you've tried as a matter-of-course:

After booting up, is history started, or do you have to do
that manually?  Have you run set -o to see if history is
enabled?  If it isn't, then set -o history.  Is a clear
command being issued from anywhere upon logout or reboot?

Just some thoughts.



No offense at all, thanks for your suggestions!  I'm currently at work so  
I'll test this when I get home (this is on a desktop running 8.3-stable).   
I've never had to do anything special when using bash on FreeBSD.  I'll be  
sure to check th output of set -o and report back here.


If there's an erroneous 'clear' command somewhere, it must be on logout  
since I can easily test this problem being that I use tmux.  :)  I also do  
not have a .bash_logout file, if that matters.


Thanks for the suggestions, I'll let you know what turns up.

--
Andre Goree
an...@drenet.info
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Bash history empty on login

2013-01-08 Thread Trond Endrestøl
On Tue, 8 Jan 2013 09:05-0500, Andre Goree wrote:

 On Tue, 08 Jan 2013 07:59:51 -0500, Dimitri Yioulos dyiou...@onpointfc.com
 wrote:
 
  
  Hope I'm not offending you if the following are things
  you've tried as a matter-of-course:
  
  After booting up, is history started, or do you have to do
  that manually?  Have you run set -o to see if history is
  enabled?  If it isn't, then set -o history.  Is a clear
  command being issued from anywhere upon logout or reboot?
  
  Just some thoughts.
  
 
 No offense at all, thanks for your suggestions!  I'm currently at work so I'll
 test this when I get home (this is on a desktop running 8.3-stable).  I've
 never had to do anything special when using bash on FreeBSD.  I'll be sure to
 check th output of set -o and report back here.
 
 If there's an erroneous 'clear' command somewhere, it must be on logout since
 I can easily test this problem being that I use tmux.  :)  I also do not have
 a .bash_logout file, if that matters.
 
 Thanks for the suggestions, I'll let you know what turns up.

What are the permissions of ~/.bash_history?

Usually they are set to 0600 in octal due to security concerns and 
rightfully so. Could they be (re)set to 0400 or even ?

-- 
+---++
| Vennlig hilsen,   | Best regards,  |
| Trond Endrestøl,  | Trond Endrestøl,   |
| IT-ansvarlig, | System administrator,  |
| Fagskolen Innlandet,  | Gjøvik Technical College, Norway,  |
| tlf. mob.   952 62 567,   | Cellular...: +47 952 62 567,   |
| sentralbord 61 14 54 00.  | Switchboard: +47 61 14 54 00.  |
+---++___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org

Re: Bash history empty on login

2013-01-08 Thread Andre Goree
On 01/08/13 09:11, Trond Endrestøl wrote:
 On Tue, 8 Jan 2013 09:05-0500, Andre Goree wrote:
 
 On Tue, 08 Jan 2013 07:59:51 -0500, Dimitri Yioulos dyiou...@onpointfc.com
 wrote:


 Hope I'm not offending you if the following are things
 you've tried as a matter-of-course:

 After booting up, is history started, or do you have to do
 that manually?  Have you run set -o to see if history is
 enabled?  If it isn't, then set -o history.  Is a clear
 command being issued from anywhere upon logout or reboot?

 Just some thoughts.


 No offense at all, thanks for your suggestions!  I'm currently at work so 
 I'll
 test this when I get home (this is on a desktop running 8.3-stable).  I've
 never had to do anything special when using bash on FreeBSD.  I'll be sure to
 check th output of set -o and report back here.

 If there's an erroneous 'clear' command somewhere, it must be on logout since
 I can easily test this problem being that I use tmux.  :)  I also do not have
 a .bash_logout file, if that matters.

 Thanks for the suggestions, I'll let you know what turns up.
 
 What are the permissions of ~/.bash_history?
 
 Usually they are set to 0600 in octal due to security concerns and 
 rightfully so. Could they be (re)set to 0400 or even ?
 

I think I've found the culprit, however:
[agoree@desktop ~]$ echo $HISTFILESIZE
1024000
[agoree@desktop ~]$ echo $HISTFILE
/home/agoree/.bash_history
[agoree@desktop ~]$ ll /home/agoree/.bash_history
-rw---  1 agoree  agoree12k Jan  5 14:09 /home/agoree/.bash_history
[agoree@desktop ~]$ cat /home/agoree/.bash_history
cat: /home/agoree/.bash_history: Input/output error
[agoree@desktop ~]$ file /home/agoree/.bash_history
/home/agoree/.bash_history: ERROR: cannot read
`/home/agoree/.bash_history' (Input/output error)

I suppose I'm in need of a scrub, eh?  Or perhaps just a tweak to
$HISTFILE until I have the time (or energy) to deal with the scrub --
probably not a good idea, but sense all my important data is kept on a
NAS...  :p


-- 
Andre Goree
an...@drenet.info
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Bash history empty on login

2013-01-08 Thread Trond Endrestøl
On Tue, 8 Jan 2013 18:49-0500, Andre Goree wrote:

 
  I think I've found the culprit, however:
  [agoree@desktop ~]$ echo $HISTFILESIZE
  1024000
  [agoree@desktop ~]$ echo $HISTFILE
  /home/agoree/.bash_history
  [agoree@desktop ~]$ ll /home/agoree/.bash_history
  -rw---  1 agoree  agoree12k Jan  5 14:09 /home/agoree/.bash_history
  [agoree@desktop ~]$ cat /home/agoree/.bash_history
  cat: /home/agoree/.bash_history: Input/output error
  [agoree@desktop ~]$ file /home/agoree/.bash_history
  /home/agoree/.bash_history: ERROR: cannot read
  `/home/agoree/.bash_history' (Input/output error)
  
  I suppose I'm in need of a scrub, eh?  Or perhaps just a tweak to
  $HISTFILE until I have the time (or energy) to deal with the scrub --
  probably not a good idea, but sense all my important data is kept on a
  NAS...  :p
  
  
   
 
 So, yeahhh...:
 
 NAMESTATE READ WRITE CKSUM
 zroot   ONLINE   0 0   586
   ad4s1dONLINE   0 0 0
   ad8s1dONLINE   0 0   586

I don't know if this was intentional, but your zroot pool is 
configured with absolutely no redundancy unless you have set the 
zfs copies property to a value greater than 1 on selected file 
systems if not all file systems. The text quoted below does not 
indicate any of this.

You should at the very least mirror your zroot pool between no less 
than 2 drives/partitions, shouldn't raidz{1,2,3} with the appropriate 
number of drives/partitions prove tempting or possible hardwarewise.

 errors: Permanent errors have been detected in the following files:
 
 /usr/local/share/icons/hicolor/128x128/apps/vlc.png
 zroot/usr:0x11ae0a
 zroot/usr:0x109118
 zroot/usr:0x11ae18
 zroot/usr:0x11ae19
 zroot/usr:0x11ae1d
 zroot/usr:0x11ae1e
 zroot/usr:0x18b61e
 zroot/usr:0x18b622
 zroot/usr:0x18b62e
 zroot/usr:0x18b637
 
 /usr/ports/sysutils/e2fsprogs/work/e2fsprogs-1.42.6/e2fsck/e2fsck.c.bak
 zroot/usr:0x18b63c
 zroot/usr:0x18b63d
 zroot/usr:0x18b641
 zroot/usr:0x18b642
 zroot/usr:0x109256
 /usr/home/agoree/.opera.bak/icons/www.google.com.idx
 /usr/home/agoree/.opera.bak/download.dat
 /usr/home/agoree/.cache/chromium/Default/Cache/data_1
 /usr/home/agoree/.opera.bak/typed_history.xml
 /usr/home/agoree/.bash_history
 zroot/usr:0x109199
 zroot/usr:0x11ad9b
 /usr/local/share/locale/fo/LC_MESSAGES/cairo-dock.mo
 /usr/local/lib/qt4/plugins/script/libqtscript_core.so.1.0.0
 zroot/var:0x98bf

I'm very sorry for your loss, but apparently these files aren't 
critical user data.

 I'll probably just go ahead and reinstall -- I've been wanting to give
 9.1 a try anyways.

Good luck and don't forget about redundancy! :D

-- 
+---++
| Vennlig hilsen,   | Best regards,  |
| Trond Endrestøl,  | Trond Endrestøl,   |
| IT-ansvarlig, | System administrator,  |
| Fagskolen Innlandet,  | Gjøvik Technical College, Norway,  |
| tlf. mob.   952 62 567,   | Cellular...: +47 952 62 567,   |
| sentralbord 61 14 54 00.  | Switchboard: +47 61 14 54 00.  |
+---++___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org

Bash history empty on login

2013-01-07 Thread Andre Goree
I'm not sure what's going on, as I've never had an issue like this in my  
years of using FreeBSD nor Linux.  Each time I login, my history file is  
empty!  I'm not sure what could be causing this, but below [1] is my  
.bashrc.  I had . ~/.bashrc in ~/.profile, but I removed it while I'm  
trying to troubleshoot this issue.  Does anyone have an idea or a  
direction to point me in?  Thanks in advance.


[1]#
# ~/.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]]  return

#PS1='[\u@\h \W]\$ '

alias ls='ls -G'
alias ll='ls -lAhp'
alias umount='sudo umount'
alias grep='grep --color'
alias nmap='sudo nmap'
alias updatedb='sudo updatedb'
alias pkg_add='sudo pkg_add'
alias pkg_delete='sudo pkg_delete'
alias top='top -aPStzj -s 1'
alias portinstall='sudo portinstall'
alias updatedb='sudo updatedb'

PS1='\[\e[1;37m\][\u@\h \W]\$\[\e[0m\] '

export PATH=$PATH:/home/agoree/bin:/usr/local/kde4/bin/

#BASH history
export HISTTIMEFORMAT=%h/%d - %H:%M:%S 
export HISTFILESIZE=10
#export VBOX_USB=usbfs

--
Using Opera's mail client: http://www.opera.com/mail/
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash pipe redirection gets stuck

2012-12-04 Thread jb
 long at rule.lv writes:

 
 Dear all,
 I stumbled upon a problem where multiple pipe redirection occasionally get
 stuck when trying to get sha256 sum of a stream.
 
 You can try to reproduce the problem if you have /usr/ports/shells/bash
 installed (output redirection used in this command is possible only in
 bash).
 Create temporary test file with command: dd if=/dev/urandom of=/tmp/file1
 bs=1k count=10
 And the command I'm using is:
 /usr/local/bin/bash -c 'cat /tmp/file1 | tee (/sbin/sha256 
 /tmp/file1.sha256)  /tmp/file1.copy' ; echo $status

I could reproduce it on FreeBSD 9.0-RELEASE-p3 on 3rd try, but after upgrade
of bash-4.1.11 to bash-4.2.37 it works (tested 30 times).
jb
 

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


bash pipe redirection gets stuck

2012-12-03 Thread long
Dear all,
I stumbled upon a problem where multiple pipe redirection occasionally get
stuck when trying to get sha256 sum of a stream.

You can try to reproduce the problem if you have /usr/ports/shells/bash
installed (output redirection used in this command is possible only in
bash).
Create temporary test file with command: dd if=/dev/urandom of=/tmp/file1
bs=1k count=10
And the command I'm using is:
/usr/local/bin/bash -c 'cat /tmp/file1 | tee (/sbin/sha256 
/tmp/file1.sha256)  /tmp/file1.copy' ; echo $status

Command gets stuck about once in 20 executions.
top output when command gets stuck (irrelevant processes removed):
  PID USERNAMETHR PRI NICE   SIZERES STATE   C   TIME   WCPU COMMAND
84073 HappyUser 1  520 17612K  2268K wait0   0:00  0.00% bash
84154 HappyUser 1  520 10084K   844K fifoow  1   0:00  0.00% tee

And more strangely, I can reproduce this problem on 9.0-RELEASE and
7.4-RELEASE-p6, but couldn't reproduce on 8.2-RELEASE-p4.

Thanks for any pointers/explanations,
Normunds

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash pipe redirection gets stuck

2012-12-03 Thread Jerry
On Mon, 3 Dec 2012 16:35:15 +0200 (EET)
l...@rule.lv articulated:

 Dear all,
 I stumbled upon a problem where multiple pipe redirection
 occasionally get stuck when trying to get sha256 sum of a stream.
 
 You can try to reproduce the problem if you
 have /usr/ports/shells/bash installed (output redirection used in
 this command is possible only in bash).
 Create temporary test file with command: dd if=/dev/urandom
 of=/tmp/file1 bs=1k count=10
 And the command I'm using is:
 /usr/local/bin/bash -c 'cat /tmp/file1 | tee (/sbin/sha256 
 /tmp/file1.sha256)  /tmp/file1.copy' ; echo $status
 
 Command gets stuck about once in 20 executions.
 top output when command gets stuck (irrelevant processes removed):
   PID USERNAMETHR PRI NICE   SIZERES STATE   C   TIME   WCPU
 COMMAND 84073 HappyUser 1  520 17612K  2268K wait0
 0:00  0.00% bash 84154 HappyUser 1  520 10084K   844K fifoow
 1   0:00  0.00% tee
 
 And more strangely, I can reproduce this problem on 9.0-RELEASE and
 7.4-RELEASE-p6, but couldn't reproduce on 8.2-RELEASE-p4.
 
 Thanks for any pointers/explanations,
 Normunds

For starters, what version of Bash? FreeBSD is still a few patches
behind the current patch level, so that is also a possibility.

I would suggest you visit:
https://lists.gnu.org/mailman/listinfo/bug-bash, subscribe to the
list and then ask your question bug-b...@gnu.org.

-- 
Jerry ♔

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.
__
Communicate!  It can't make things any worse.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org

Re: bash pipe redirection gets stuck

2012-12-03 Thread Frank Reppin

On 03.12.12 15:35, l...@rule.lv wrote:
[...]

I stumbled upon a problem where multiple pipe redirection occasionally get
stuck when trying to get sha256 sum of a stream.

You can try to reproduce the problem if you have /usr/ports/shells/bash
installed (output redirection used in this command is possible only in
bash).
Create temporary test file with command: dd if=/dev/urandom of=/tmp/file1
bs=1k count=10
And the command I'm using is:
/usr/local/bin/bash -c 'cat /tmp/file1 | tee (/sbin/sha256 
/tmp/file1.sha256)  /tmp/file1.copy' ; echo $status

Command gets stuck about once in 20 executions.
top output when command gets stuck (irrelevant processes removed):
   PID USERNAMETHR PRI NICE   SIZERES STATE   C   TIME   WCPU COMMAND
84073 HappyUser 1  520 17612K  2268K wait0   0:00  0.00% bash
84154 HappyUser 1  520 10084K   844K fifoow  1   0:00  0.00% tee

And more strangely, I can reproduce this problem on 9.0-RELEASE and
7.4-RELEASE-p6, but couldn't reproduce on 8.2-RELEASE-p4.

It maybe couldn't gather more randomness from /dev/random?
The random(4) manpage suggests that there's (theoretically)
indeed a chance that it blocks - see the section about
'kern.random.sys.seeded'.
So in fact - when you think the command gets stuck - it's
probably not bash related at all.

cheers,
Frank Reppin

--
43rd Law of Computing:
Anything that can go wr
fortune: Segmentation violation -- Core dumped
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash pipe redirection gets stuck

2012-12-03 Thread jb
 long at rule.lv writes:

 
 Dear all,
 I stumbled upon a problem where multiple pipe redirection occasionally get
 stuck when trying to get sha256 sum of a stream.
 
 You can try to reproduce the problem if you have /usr/ports/shells/bash
 installed (output redirection used in this command is possible only in
 bash).
 Create temporary test file with command: dd if=/dev/urandom of=/tmp/file1
 bs=1k count=10
 And the command I'm using is:
 /usr/local/bin/bash -c 'cat /tmp/file1 | tee (/sbin/sha256 
 /tmp/file1.sha256)  /tmp/file1.copy' ; echo $status
 ...

Do you get stuck with this ? Does it make any difference ?
/usr/local/bin/bash -c 'cat /tmp/file1 | tee /tmp/file1.copy | /sbin/sha256 \
/tmp/file1.sha256' ; echo $status

jb




___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash pipe redirection gets stuck

2012-12-03 Thread jb
jb jb.1234abcd at gmail.com writes:

 ...
 Do you get stuck with this ? Does it make any difference ?

I missed a redirector - sorry about that; the entry should be:
/usr/local/bin/bash -c 'cat /tmp/file1 | tee /tmp/file1.copy | /sbin/sha256  \
/tmp/file1.sha256' ; echo $status

jb



___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash pipe redirection gets stuck

2012-12-03 Thread long
 On 03.12.12 15:35, l...@rule.lv wrote:
 [...]
 I stumbled upon a problem where multiple pipe redirection occasionally
 get
 stuck when trying to get sha256 sum of a stream.

 You can try to reproduce the problem if you have /usr/ports/shells/bash
 installed (output redirection used in this command is possible only in
 bash).
 Create temporary test file with command: dd if=/dev/urandom
 of=/tmp/file1
 bs=1k count=10
 And the command I'm using is:
 /usr/local/bin/bash -c 'cat /tmp/file1 | tee (/sbin/sha256 
 /tmp/file1.sha256)  /tmp/file1.copy' ; echo $status

 Command gets stuck about once in 20 executions.
 top output when command gets stuck (irrelevant processes removed):
PID USERNAMETHR PRI NICE   SIZERES STATE   C   TIME   WCPU
 COMMAND
 84073 HappyUser 1  520 17612K  2268K wait0   0:00  0.00%
 bash
 84154 HappyUser 1  520 10084K   844K fifoow  1   0:00  0.00% tee

 And more strangely, I can reproduce this problem on 9.0-RELEASE and
 7.4-RELEASE-p6, but couldn't reproduce on 8.2-RELEASE-p4.
 It maybe couldn't gather more randomness from /dev/random?
 The random(4) manpage suggests that there's (theoretically)
 indeed a chance that it blocks - see the section about
 'kern.random.sys.seeded'.
 So in fact - when you think the command gets stuck - it's
 probably not bash related at all.

 cheers,
 Frank Reppin

 --
 43rd Law of Computing:
  Anything that can go wr
 fortune: Segmentation violation -- Core dumped



Thanks for your answer, but randomly generated file is created fine (it is
only for illustrative purpose). As far as I understand, thing that blocks
is tee inside bash command or pipeline.

Thanks and best regards,
Normunds

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Re: bash Shell Scripting Question

2012-09-20 Thread Jan Henrik Sylvester

On 09/20/2012 04:29, Polytropon wrote:

Correct. You could use different approaches which may or may
not fail due to the directory names you will encounter (like
directories with spaces or special characters).

#!/bin/sh
for DIR in `ls -LF | grep \/`; do
cd ${DIR}
# do stuff
done

Or you can use piping:

#!/bin/sh
ls -LF | grep \/ | while read DIR; do
cd ${DIR}
# do stuff
done

I'm quite confident there are even more elegant and fault-
tolerant solutions. You would maybe have to tweak the ls
command or play with IFS (space or newline).


Even if you start quoting ${DIR}, the first one will fail at least for 
names containing spaces, the second one at least for names starting with 
spaces. As you said, you would have to change IFS to maybe slash and 
newline, assuming that you do not have names containing newlines, in 
which case the approach cannot work.


I understand that you want all directories and links to directories not 
starting with a period. How about trying all files not starting with a 
period and skipping the non directories:


#!/bin/sh
for DIR in *
do
cd $DIR /dev/null 21 || continue
pwd
cd -  /dev/null
done

This one works with names containing spaces or even newlines and does 
not even need to spawn external commands or subshells. It may have other 
caveats, though.


Cheers,
Jan Henrik
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash Shell Scripting Question

2012-09-20 Thread Martin McCormick
Many thanks! The for loop was what was needed.

Polytropon writes:
 Just a sidenote: If you're not using bash-specific functionality
 and intend to make your script portable, use #!/bin/sh instead.

I always start out that way for that very reason. I needed some
random number functions and arithmetic for another part of the
script so I ended up going to bash.

  while read dirname; do
 
 Attention: dirname (/usr/bin/dirname) is a binary!

You are so correct!  Thank you.

Continuing;

 Correct. You could use different approaches which may or may
 not fail due to the directory names you will encounter (like
 directories with spaces or special characters).

In this application, all the directories will be
non-problematic, but point well taken.

 
 #!/bin/sh
 for DIR in `ls -LF | grep \/`; do
 cd ${DIR}
 # do stuff
 done

That works perfectly. Again many thanks.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash Shell Scripting Question

2012-09-20 Thread Polytropon
On Thu, 20 Sep 2012 11:16:40 +0200, Jan Henrik Sylvester wrote:
 On 09/20/2012 04:29, Polytropon wrote:
  Correct. You could use different approaches which may or may
  not fail due to the directory names you will encounter (like
  directories with spaces or special characters).
 
  #!/bin/sh
  for DIR in `ls -LF | grep \/`; do
  cd ${DIR}
  # do stuff
  done
 
  Or you can use piping:
 
  #!/bin/sh
  ls -LF | grep \/ | while read DIR; do
  cd ${DIR}
  # do stuff
  done
 
  I'm quite confident there are even more elegant and fault-
  tolerant solutions. You would maybe have to tweak the ls
  command or play with IFS (space or newline).
 
 Even if you start quoting ${DIR}, the first one will fail at least for 
 names containing spaces, the second one at least for names starting with 
 spaces. As you said, you would have to change IFS to maybe slash and 
 newline, assuming that you do not have names containing newlines, in 
 which case the approach cannot work.

You are fully correct: In order to create an iterator that
provides valid directory names, even for the cases where
unusual characters (which are _valid_ characters for file
names and directory names) are included, is not trivial.

Allow me to point to those two articles which mention different
approaches and show why they are wrong. :-)

David A. Wheeler:
Filenames and Pathnames in Shell: How to do it correctly
http://www.dwheeler.com/essays/filenames-in-shell.html

David A. Wheeler:
Fixing Unix/Linux/POSIX Filenames:
Control Characters (such as Newline), Leading Dashes, and Other Problems
http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html



 I understand that you want all directories and links to directories not 
 starting with a period. How about trying all files not starting with a 
 period and skipping the non directories:
 
 #!/bin/sh
 for DIR in *
 do
  cd $DIR /dev/null 21 || continue
  pwd
  cd -  /dev/null
 done
 
 This one works with names containing spaces or even newlines and does 
 not even need to spawn external commands or subshells. It may have other 
 caveats, though.

It will work - it delegates resolving * to the shell instead
of having a different program (ls | grep, find) doing that.





-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


bash Shell Scripting Question

2012-09-19 Thread Martin McCormick
I just discovered a knowledge deficiency on my part that
I can't seem to resolve.

If one writes a loop of the following form:

#!/usr/local/bin/bash 
ls -LF |grep \/ /tmp/files
while read dirname; do
cd $dirname
#Do whatever commands to be repeated in each directory.
done  /tmp/files

This works quite well but it is shall we say sloppy
because it creates a file that then must be cleaned up and its
name needs to be made unique, etc.

The standard output of the `ls -LF |grep \/` command
needs to look like a file and all should be well. I thought the
 redirection would pickup the standard output.

Thanks for ideas.

Martin McCormick
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash Shell Scripting Question

2012-09-19 Thread Mihai Donțu
On Wed, 19 Sep 2012 21:03:11 -0500 Martin McCormick wrote:
 #!/usr/local/bin/bash 
 ls -LF |grep \/ /tmp/files
 while read dirname; do
 cd $dirname
 #Do whatever commands to be repeated in each directory.
 done  /tmp/files
 

How about:

   ls -LF | grep \/ | while read dirname; do
   cd $dirname
   # do stuff
   done

or:

   find . -maxdepth 1 -type d | while read dirname; do
   cd $dirname
   # do stuff
   done

or even:

   find . -maxdepth 1 -type d ! -name .* | while read dirname; do
   cd $dirname
   # do stuff
   done

-- 
Mihai Donțu
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash Shell Scripting Question

2012-09-19 Thread Polytropon
On Wed, 19 Sep 2012 21:03:11 -0500, Martin McCormick wrote:
   I just discovered a knowledge deficiency on my part that
 I can't seem to resolve.
 
   If one writes a loop of the following form:
 
 #!/usr/local/bin/bash 

Just a sidenote: If you're not using bash-specific functionality
and intend to make your script portable, use #!/bin/sh instead.



 ls -LF |grep \/ /tmp/files
 while read dirname; do

Attention: dirname (/usr/bin/dirname) is a binary!



 cd $dirname
 #Do whatever commands to be repeated in each directory.
 done  /tmp/files
 
   This works quite well but it is shall we say sloppy
 because it creates a file that then must be cleaned up and its
 name needs to be made unique, etc.

Correct. You could use different approaches which may or may
not fail due to the directory names you will encounter (like
directories with spaces or special characters).

#!/bin/sh
for DIR in `ls -LF | grep \/`; do
cd ${DIR}
# do stuff
done

Or you can use piping:

#!/bin/sh
ls -LF | grep \/ | while read DIR; do
cd ${DIR}
# do stuff
done

I'm quite confident there are even more elegant and fault-
tolerant solutions. You would maybe have to tweak the ls
command or play with IFS (space or newline).



   The standard output of the `ls -LF |grep \/` command
 needs to look like a file and all should be well. I thought the
  redirection would pickup the standard output.

No, the  and  redirections basically operate on files,
while pipes redirect strandard output to standard input.
So for example,

somecommand  /tmp/somefile

refers to a file that has to exist, while

somecommand  `someothercommand`

does not take someothercommand's output (stdout), but instead
interprets it as a file specification and then reads from that
files (if existing).




-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


A bash scripting question

2012-06-21 Thread Odhiambo Washington
How Can I simplify/perfect the following script, so that I read _ALL_ the
lines in the file and act on the content as shown below, so that I do not
have to specifiy an action per line?

This below is doing exactly what i need BUT reading one line at a time
untill the 10th line, if i want more i add manually...
This might help some1 someday! But if there is a way to perfect it please
do so.

#!/usr/local/bin/bash

smsfile=email_to_sms
`grep Subject /var/spool/mail/sms $smsfile`
if [[ -s $smsfile ]] ; then
cat /dev/null  /var/spool/mail/sms
sed -i 's/Subject: //g' $smsfile
echo `sed -n '1p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==1
{print $1}' $smsfile`
echo `sed -n '2p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==2
{print $1}' $smsfile`
echo `sed -n '3p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==3
{print $1}' $smsfile`
echo `sed -n '4p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==4
{print $1}' $smsfile`
echo `sed -n '5p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==5
{print $1}' $smsfile`
echo `sed -n '6p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==6
{print $1}' $smsfile`
echo `sed -n '7p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==7
{print $1}' $smsfile`
echo `sed -n '8p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==8
{print $1}' $smsfile`
echo `sed -n '9p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==9
{print $1}' $smsfile`
echo `sed -n '10p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==10
{print $1}' $smsfile`
else
echo ***Sorry the SMS FILE $smsfile is empty.
fi
gammu-smsd start
cat email_to_sms  email_to_sms2
cat /dev/null  email_to_sms




-- 
Best regards,
Odhiambo WASHINGTON,
Nairobi,KE
+254733744121/+254722743223
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
I can't hear you -- I'm using the scrambler.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: A bash scripting question

2012-06-21 Thread Devin Teske

On Jun 21, 2012, at 6:40 AM, Odhiambo Washington wrote:

 How Can I simplify/perfect the following script, so that I read _ALL_ the
 lines in the file and act on the content as shown below, so that I do not
 have to specifiy an action per line?
 
 This below is doing exactly what i need BUT reading one line at a time
 untill the 10th line, if i want more i add manually...
 This might help some1 someday! But if there is a way to perfect it please
 do so.
 
 #!/usr/local/bin/bash
 
 smsfile=email_to_sms
 `grep Subject /var/spool/mail/sms $smsfile`
 if [[ -s $smsfile ]] ; then
 cat /dev/null  /var/spool/mail/sms
 sed -i 's/Subject: //g' $smsfile
 echo `sed -n '1p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==1
 {print $1}' $smsfile`
 echo `sed -n '2p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==2
 {print $1}' $smsfile`
 echo `sed -n '3p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==3
 {print $1}' $smsfile`
 echo `sed -n '4p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==4
 {print $1}' $smsfile`
 echo `sed -n '5p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==5
 {print $1}' $smsfile`
 echo `sed -n '6p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==6
 {print $1}' $smsfile`
 echo `sed -n '7p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==7
 {print $1}' $smsfile`
 echo `sed -n '8p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==8
 {print $1}' $smsfile`
 echo `sed -n '9p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==9
 {print $1}' $smsfile`
 echo `sed -n '10p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==10
 {print $1}' $smsfile`
 else
 echo ***Sorry the SMS FILE $smsfile is empty.
 fi
 gammu-smsd start
 cat email_to_sms  email_to_sms2
 cat /dev/null  email_to_sms
 

Try the following…

#!/bin/sh
smsfile=email_to_sms
spoolfile=/var/spol/mail/sms
grep Subject $spoolfile  $smsfile
if [ -s $smsfile ]; then
:  $spoolfile
sed -e 's/Subject: //g' $smsfile | awk '
{
if (NR  10) exit
print | /usr/bin/gammu --sendsms TEXT  $1
}'
else
echo ***Sorry the SMS FILE $smsfile is empty.
fi
gammu-smsd start
cat $smsfile  email_to_sms2
:  $smsfile

-- 
Devin

_
The information contained in this message is proprietary and/or confidential. 
If you are not the intended recipient, please: (i) delete the message and all 
copies; (ii) do not disclose, distribute or use the message in any manner; and 
(iii) notify the sender immediately. In addition, please be aware that any 
message addressed to our domain is subject to archiving and review by persons 
other than the intended recipient. Thank you.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: A bash scripting question

2012-06-21 Thread CyberLeo Kitsana
On 06/21/2012 08:40 AM, Odhiambo Washington wrote:
 How Can I simplify/perfect the following script, so that I read _ALL_ the
 lines in the file and act on the content as shown below, so that I do not
 have to specifiy an action per line?
 
 This below is doing exactly what i need BUT reading one line at a time
 untill the 10th line, if i want more i add manually...
 This might help some1 someday! But if there is a way to perfect it please
 do so.
 
 #!/usr/local/bin/bash
 
 smsfile=email_to_sms
 `grep Subject /var/spool/mail/sms $smsfile`
 if [[ -s $smsfile ]] ; then
 cat /dev/null  /var/spool/mail/sms
 sed -i 's/Subject: //g' $smsfile
 echo `sed -n '1p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==1
 {print $1}' $smsfile`
 echo `sed -n '2p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==2
 {print $1}' $smsfile`
 echo `sed -n '3p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==3
 {print $1}' $smsfile`
 echo `sed -n '4p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==4
 {print $1}' $smsfile`
 echo `sed -n '5p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==5
 {print $1}' $smsfile`
 echo `sed -n '6p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==6
 {print $1}' $smsfile`
 echo `sed -n '7p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==7
 {print $1}' $smsfile`
 echo `sed -n '8p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==8
 {print $1}' $smsfile`
 echo `sed -n '9p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==9
 {print $1}' $smsfile`
 echo `sed -n '10p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==10
 {print $1}' $smsfile`
 else
 echo ***Sorry the SMS FILE $smsfile is empty.
 fi
 gammu-smsd start
 cat email_to_sms  email_to_sms2
 cat /dev/null  email_to_sms

Off the top of my head:

8
#!/bin/sh -e

sed -e '/^Subject: /!d; s/^Subject: //' /var/spool/mail/sms  ${smsfile}

:/var/spool/mail/sms

xargs -L1 /usr/bin/gammu --sendsms TEXT  ${smsfile}

mv -f ${smsfile} ${smsfile}.bak
8

No loops necessary.

By the way, what's gammu, and why is it in /usr/bin ?

-- 
Fuzzy love,
-CyberLeo
Technical Administrator
CyberLeo.Net Webhosting
http://www.CyberLeo.Net
cyber...@cyberleo.net

Furry Peace! - http://.fur.com/peace/
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: A bash scripting question

2012-06-21 Thread Julian H. Stacey
CyberLeo Kitsana wrote Odhiambo Washington:

 By the way, what's gammu, 

/usr/ports/comms/gammu presumably
( for mobile phone connection )

 and why is it in /usr/bin ?

Pass.

Cheers,
Julian
-- 
Julian Stacey, BSD Unix Linux C Sys Eng Consultants Munich http://berklix.com
 Reply below not above, cumulative like a play script,  indent with  .
 Format: Plain text. Not HTML, multipart/alternative, base64, quoted-printable.
Mail from @yahoo dumped @berklix.  http://berklix.org/yahoo/
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


RE: A bash scripting question

2012-06-21 Thread dteske


 -Original Message-
 From: owner-freebsd-questi...@freebsd.org [mailto:owner-freebsd-
 questi...@freebsd.org] On Behalf Of Devin Teske
 Sent: Thursday, June 21, 2012 9:24 AM
 To: Odhiambo Washington
 Cc: questions
 Subject: Re: A bash scripting question
 
 
 On Jun 21, 2012, at 6:40 AM, Odhiambo Washington wrote:
 
  How Can I simplify/perfect the following script, so that I read _ALL_ the
  lines in the file and act on the content as shown below, so that I do not
  have to specifiy an action per line?
 
  This below is doing exactly what i need BUT reading one line at a time
  untill the 10th line, if i want more i add manually...
  This might help some1 someday! But if there is a way to perfect it please
  do so.
 
  #!/usr/local/bin/bash
 
  smsfile=email_to_sms
  `grep Subject /var/spool/mail/sms $smsfile`
  if [[ -s $smsfile ]] ; then
  cat /dev/null  /var/spool/mail/sms
  sed -i 's/Subject: //g' $smsfile
  echo `sed -n '1p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==1
  {print $1}' $smsfile`
  echo `sed -n '2p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==2
  {print $1}' $smsfile`
  echo `sed -n '3p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==3
  {print $1}' $smsfile`
  echo `sed -n '4p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==4
  {print $1}' $smsfile`
  echo `sed -n '5p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==5
  {print $1}' $smsfile`
  echo `sed -n '6p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==6
  {print $1}' $smsfile`
  echo `sed -n '7p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==7
  {print $1}' $smsfile`
  echo `sed -n '8p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==8
  {print $1}' $smsfile`
  echo `sed -n '9p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==9
  {print $1}' $smsfile`
  echo `sed -n '10p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==10
  {print $1}' $smsfile`
  else
  echo ***Sorry the SMS FILE $smsfile is empty.
  fi
  gammu-smsd start
  cat email_to_sms  email_to_sms2
  cat /dev/null  email_to_sms
 
 
 Try the following.
 
 #!/bin/sh
 smsfile=email_to_sms
 spoolfile=/var/spol/mail/sms
 grep Subject $spoolfile  $smsfile
 if [ -s $smsfile ]; then
   :  $spoolfile
   sed -e 's/Subject: //g' $smsfile | awk '
   {
   if (NR  10) exit
   print | /usr/bin/gammu --sendsms TEXT  $1
   }'
 else
   echo ***Sorry the SMS FILE $smsfile is
 empty.
 fi
 gammu-smsd start
 cat $smsfile  email_to_sms2
 :  $smsfile
 

I can beat my original response (above), while retaining original
functionality...

#!/bin/sh
spoolfile=/var/spool/mail/sms
awk -v pat=^Subject:  '
$0 ~ pat {
sub(pat,)
print | /usr/bin/gammu --sendsms TEXT  $1
}' $spoolfile

Or, as a shell One-Liner (compatible with any shell and any awk)...

awk -v pat=^Subject:  '$0~pat{sub(pat,);print|/usr/bin/gammu --sendsms TEXT
$1}' $spoolfile
-- 
Devin


_
The information contained in this message is proprietary and/or confidential. 
If you are not the intended recipient, please: (i) delete the message and all 
copies; (ii) do not disclose, distribute or use the message in any manner; and 
(iii) notify the sender immediately. In addition, please be aware that any 
message addressed to our domain is subject to archiving and review by persons 
other than the intended recipient. Thank you.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


RE: A bash scripting question

2012-06-21 Thread dteske


 -Original Message-
 From: owner-freebsd-questi...@freebsd.org [mailto:owner-freebsd-
 questi...@freebsd.org] On Behalf Of dte...@freebsd.org
 Sent: Thursday, June 21, 2012 12:57 PM
 To: 'Odhiambo Washington'
 Cc: 'questions'
 Subject: RE: A bash scripting question
 
 
 
  -Original Message-
  From: owner-freebsd-questi...@freebsd.org [mailto:owner-freebsd-
  questi...@freebsd.org] On Behalf Of Devin Teske
  Sent: Thursday, June 21, 2012 9:24 AM
  To: Odhiambo Washington
  Cc: questions
  Subject: Re: A bash scripting question
 
 
  On Jun 21, 2012, at 6:40 AM, Odhiambo Washington wrote:
 
   How Can I simplify/perfect the following script, so that I read _ALL_ the
   lines in the file and act on the content as shown below, so that I do not
   have to specifiy an action per line?
  
   This below is doing exactly what i need BUT reading one line at a time
   untill the 10th line, if i want more i add manually...
   This might help some1 someday! But if there is a way to perfect it please
   do so.
  
   #!/usr/local/bin/bash
  
   smsfile=email_to_sms
   `grep Subject /var/spool/mail/sms $smsfile`
   if [[ -s $smsfile ]] ; then
   cat /dev/null  /var/spool/mail/sms
   sed -i 's/Subject: //g' $smsfile
   echo `sed -n '1p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==1
   {print $1}' $smsfile`
   echo `sed -n '2p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==2
   {print $1}' $smsfile`
   echo `sed -n '3p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==3
   {print $1}' $smsfile`
   echo `sed -n '4p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==4
   {print $1}' $smsfile`
   echo `sed -n '5p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==5
   {print $1}' $smsfile`
   echo `sed -n '6p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==6
   {print $1}' $smsfile`
   echo `sed -n '7p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==7
   {print $1}' $smsfile`
   echo `sed -n '8p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==8
   {print $1}' $smsfile`
   echo `sed -n '9p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==9
   {print $1}' $smsfile`
   echo `sed -n '10p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==10
   {print $1}' $smsfile`
   else
   echo ***Sorry the SMS FILE $smsfile is empty.
   fi
   gammu-smsd start
   cat email_to_sms  email_to_sms2
   cat /dev/null  email_to_sms
  
 
  Try the following.
 
  #!/bin/sh
  smsfile=email_to_sms
  spoolfile=/var/spol/mail/sms
  grep Subject $spoolfile  $smsfile
  if [ -s $smsfile ]; then
  :  $spoolfile
  sed -e 's/Subject: //g' $smsfile | awk '
  {
  if (NR  10) exit
  print | /usr/bin/gammu --sendsms TEXT  $1
  }'
  else
  echo ***Sorry the SMS FILE $smsfile is
  empty.
  fi
  gammu-smsd start
  cat $smsfile  email_to_sms2
  :  $smsfile
 
 
 I can beat my original response (above), while retaining original
 functionality...
 
 #!/bin/sh
 spoolfile=/var/spool/mail/sms
 awk -v pat=^Subject:  '
 $0 ~ pat {
 sub(pat,)
 print | /usr/bin/gammu --sendsms TEXT  $1
 }' $spoolfile
 

Actually, some functionality was lost in the above translation, let me add the
missing functionality back-in...

#!/bin/sh
spoolfile=/var/spool/mail/sms
awk -v pat=^Subject:  '
BEGIN { found = 0 }
$0 ~ pat {
found++
sub(pat, )
print | /usr/bin/gammu --sendsms TEXT  $1
}
END {
if ( ! found )
printf %sSorry the SMS FILE \%s\ is empty.%s\n,
   ***, FILENAME, ***
exit ! found
}' $spoolfile  :  $spoolfile


 Or, as a shell One-Liner (compatible with any shell and any awk)...

The above doesn't translate so-well into a one-liner (unless you can stomach
really long lines 80 chars), but here it is...

awk -v pat=^Subject:  'BEGIN{found=0}$0~pat{found++;sub(pat,
);print|/usr/bin/gammu --sendsms TEXT $1}END{if(!found)printf %sSorry the
SMS FILE \%s\ is empty.%s\n,***,FILENAME,***;exit
!found}' /var/spool/mail/sms  : /var/spool/mail/sms
-- 
Devin

P.S. I think the above is the best you can do.

_
The information contained in this message is proprietary and/or confidential. 
If you are not the intended recipient, please: (i) delete the message and all 
copies; (ii) do not disclose, distribute or use the message in any manner; and 
(iii) notify the sender immediately. In addition, please be aware that any 
message addressed to our domain is subject to archiving and review by persons 
other than the intended recipient. Thank you.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re:[SOLVED] bash LC_COLLATE or LC_ALL set “C” not sort in dictionary order.

2012-02-01 Thread Edward Martinez

On 01/31/12 12:22, Robert Bonomi wrote:

`


Edward wrote:

On 01/31/12 06:31, Robert Bonomi wrote:

   Hi,

   Been trying to get BASH to sort set characters in  dictionary order.
  I typed locale and it shows LC_COLLATE and LC_ALL are set to C
thought that was enough to work,
  however when i type metacharacters:  set character; any character,
something like this:

  ls  [a-cx-y]*

   bash does not sort in dictionary order; file   Binarc does not
list.


*OF*COURSE* it doesn't.  Unix is _case_sensitive_.  You specified a lower-
case only (in the C locale) pattern.  Naturally, it doesn't match a file
with an upper-case character in it.

Note: in the 'C' locale, characters are sorted on the underlying byte value.
Thus you will get all the upper-case matches before any lower-case match.

To get upper-and-lower case files in the C locale, you will have to use:
ls [A-CX-Ya-cx-y]*

IF you speciy a different charset for collating, you _may_ get upper/lower
case characters sorted adjacently.  See the specifications for the charset
in question.



  Thanks for reply!

   I meant LC_COLLATE being  set to en_US.UTF-8 not C.

AH.  you lied (not necessarily maliciously, or intentionally) about the
nature of the problem.  disregard my rant.

The short answer to the revised situation is 'it depends on how the charset
collating sequence is deifined'.  AND _which_ release of FreeBSD you are
using, and thus which version of bash.

   I have been digging around and discovered  linux's bash is  not 
working correctly on this matter and numerous  users  have file bug 
reports about it.  FreeBSD's bash is fine:


   https://bugs.archlinux.org/task/24553
   https://bugs.launchpad.net/ubuntu/+source/bash/+bug/120687
   http://teaching.idallen.com/net2003/06w/notes/character_sets.txt

i will continue using either character classes and upper/lower case 
charsets when defining wildcards

   thanks for the help.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


bash LC_COLLATE or LC_ALL set “C” not sort in dictionary order.

2012-01-31 Thread Edward Martinez




Hi,

Been trying to get BASH to sort set characters in  dictionary order.
   I typed locale and it shows LC_COLLATE and LC_ALL are set to C 
thought that was enough to work,
   however when i type metacharacters:  set character; any character, 
something like this:


   ls  [a-cx-y]*

bash does not sort in dictionary order; file   Binarc does not  
list.


Am I leaving something out?




___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash LC_COLLATE or LC_ALL set “C” not sort in dictionary order.

2012-01-31 Thread Robert Bonomi
 From owner-freebsd-questi...@freebsd.org  Tue Jan 31 05:45:47 2012
 Date: Tue, 31 Jan 2012 04:45:36 -0800
 From: Edward Martinez eam1edw...@gmail.com
 To: FreeBSD Questions freebsd-questions@freebsd.org
 Subject: bash  LC_COLLATE or LC_ALL set =?windows-1252?q?=93C=94_not__sort?=
  =?windows-1252?q?_in_dictionary_order=2E?=




  Hi,

  Been trying to get BASH to sort set characters in  dictionary order.
 I typed locale and it shows LC_COLLATE and LC_ALL are set to C 
 thought that was enough to work,
 however when i type metacharacters:  set character; any character, 
 something like this:

 ls  [a-cx-y]*

  bash does not sort in dictionary order; file   Binarc does not  
 list.


*OF*COURSE* it doesn't.  Unix is _case_sensitive_.  You specified a lower-
case only (in the C locale) pattern.  Naturally, it doesn't match a file 
with an upper-case character in it.

Note: in the 'C' locale, characters are sorted on the underlying byte value.
Thus you will get all the upper-case matches before any lower-case match.

To get upper-and-lower case files in the C locale, you will have to use:
  ls [A-CX-Ya-cx-y]* 

IF you speciy a different charset for collating, you _may_ get upper/lower
case characters sorted adjacently.  See the specifications for the charset
in question.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash LC_COLLATE or LC_ALL set “C” not sort in dictionary order.

2012-01-31 Thread Edward Martinez

On 01/31/12 06:31, Robert Bonomi wrote:

 From owner-freebsd-questi...@freebsd.org  Tue Jan 31 05:45:47 2012
Date: Tue, 31 Jan 2012 04:45:36 -0800
From: Edward Martinezeam1edw...@gmail.com
To: FreeBSD Questionsfreebsd-questions@freebsd.org
Subject: bash  LC_COLLATE or LC_ALL set =?windows-1252?q?=93C=94_not__sort?=
  =?windows-1252?q?_in_dictionary_order=2E?=




  Hi,

  Been trying to get BASH to sort set characters in  dictionary order.
 I typed locale and it shows LC_COLLATE and LC_ALL are set to C
thought that was enough to work,
 however when i type metacharacters:  set character; any character,
something like this:

 ls  [a-cx-y]*

  bash does not sort in dictionary order; file   Binarc does not
list.


*OF*COURSE* it doesn't.  Unix is _case_sensitive_.  You specified a lower-
case only (in the C locale) pattern.  Naturally, it doesn't match a file
with an upper-case character in it.

Note: in the 'C' locale, characters are sorted on the underlying byte value.
Thus you will get all the upper-case matches before any lower-case match.

To get upper-and-lower case files in the C locale, you will have to use:
   ls [A-CX-Ya-cx-y]*

IF you speciy a different charset for collating, you _may_ get upper/lower
case characters sorted adjacently.  See the specifications for the charset
in question.



Thanks for reply!

 I meant LC_COLLATE being  set to en_US.UTF-8 not C.  linux and 
solaris  shows both  upper and lowercase when set characters like 
[a-cx-y] and others   are used. when LC_COLLATE is set to  en_US.UTF-8.
 I thought it could be also done in FreeBSD's  bash  when   
LC_COLLATE  is  set to en_US.UTF-8


in linux LC_COLLATE is set to en_US,UTF-8
eam@localhost ~/testdir $ locale
LANG=
LC_CTYPE=POSIX
LC_NUMERIC=POSIX
LC_TIME=POSIX
*LC_COLLATE=en_US.UTF-8*
LC_MONETARY=POSIX
LC_MESSAGES=POSIX
LC_PAPER=POSIX
LC_NAME=POSIX
LC_ADDRESS=POSIX
LC_TELEPHONE=POSIX
LC_MEASUREMENT=POSIX
LC_IDENTIFICATION=POSIX
LC_ALL=


And when i type the following it shows both:

eam@localhost ~/testdir $ ls [a-cx-y]*
bincar  Bincar

eam@localhost ~/testdir $ ls [a-z]*
bincar  Bincar  file  File  zcar









___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash LC_COLLATE or LC_ALL set “C” not sort in dictionary order.

2012-01-31 Thread Jerry
On Tue, 31 Jan 2012 12:05:57 -0800
Edward Martinez articulated:

   I meant LC_COLLATE being  set to en_US.UTF-8 not C.  linux and 
 solaris  shows both  upper and lowercase when set characters like 
 [a-cx-y] and others   are used. when LC_COLLATE is set to
 en_US.UTF-8. I thought it could be also done in FreeBSD's  bash
 when LC_COLLATE  is  set to en_US.UTF-8

What version of Bash?

-- 
Jerry ♔

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.
__

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


why newline scape sequence does not work in Freebsd's bash

2011-12-30 Thread Edward Martinez

Hello,


Why  the scape sequence; newline (\n) does not work  in  FreeBSD's  
bash,  However, it works  both  in Linux and Solaris bash?



For instance, when i type something basic using the newline scape 
sequence in FreeBSD bash i get this:


   $ FRUIT_BASKET=apple oranges pears
   $ echo My fruit basket contains:\n$FRUIT_BASKET
My fruit basket contains:\napple oranges pears


 the newline  becomes part of stdout, but it works in linux and 
solaris; the output is shown in two separate lines.
 is there is setting i have to change in FreeBSD's shell  init file so 
it will behave like linux and solaris bash shell or use just use printf?

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: why newline scape sequence does not work in Freebsd's bash

2011-12-30 Thread Любомир Григоров
try with the -e flag:

$ FRUIT_BASKET=apples oranges pears
$ echo -e 'My fruit basket contains: \n $FRUIT_BASKET'
My fruit basket contains:
$FRUIT_BASKET


Why  the scape sequence; newline (\n) does not work  in  FreeBSD's  bash,
 However, it works  both  in Linux and Solaris bash?


-- 
Lyubomir Grigorov (bgalakazam)
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: why newline scape sequence does not work in Freebsd's bash

2011-12-30 Thread Любомир Григоров
I used ' singe quotes, so double quotes is:

$ FRUIT_BASKET=apples oranges pears
$ echo -e My fruit basket contains: \n $FRUIT_BASKET
My fruit basket contains:
apples oranges pears


На 30 декември 2011, 17:04, Любомир Григоров nm.kn...@gmail.com написа:

 try with the -e flag:

 $ FRUIT_BASKET=apples oranges pears
 $ echo -e 'My fruit basket contains: \n $FRUIT_BASKET'
 My fruit basket contains:
 $FRUIT_BASKET


 Why  the scape sequence; newline (\n) does not work  in  FreeBSD's  bash,
  However, it works  both  in Linux and Solaris bash?


 --
 Lyubomir Grigorov (bgalakazam)




-- 
Lyubomir Grigorov (bgalakazam)
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: why newline scape sequence does not work in Freebsd's bash

2011-12-30 Thread Edward Martinez

On 12/30/11 17:06, Любомир Григоров wrote:

I used ' singe quotes, so double quotes is:

$ FRUIT_BASKET=apples oranges pears
$ echo -e My fruit basket contains: \n $FRUIT_BASKET
My fruit basket contains:
apples oranges pears



   Thanks for the help, it worked. I find it interesting that FreeBSD's 
echo man page does not mention the -e option is needed  to
enable  backslash escapes. I   remembered  why it worked on linux 
is because i created an  echo alias with the -e option.

So i will do the same for FreeBSD.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: why newline scape sequence does not work in Freebsd's bash

2011-12-30 Thread Erik Trulsson
On Fri, Dec 30, 2011 at 06:47:45PM -0800, Edward Martinez wrote:
 On 12/30/11 17:06, ???  wrote:
  I used ' singe quotes, so double quotes is:
 
  $ FRUIT_BASKET=apples oranges pears
  $ echo -e My fruit basket contains: \n $FRUIT_BASKET
  My fruit basket contains:
  apples oranges pears
 
 
 Thanks for the help, it worked. I find it interesting that FreeBSD's 
 echo man page does not mention the -e option is needed  to
  enable  backslash escapes. I   remembered  why it worked on linux 
 is because i created an  echo alias with the -e option.
  So i will do the same for FreeBSD.

The echo(1) manpage on FreeBSD doesn't say anything about '-e' because
that version of echo doesn't have such an option.
The echo you were actually using is the one builtin into bash and
is described in the bash(1) manpage (including mention of the -e
option.)


-- 
Insert your favourite quote here.
Erik Trulsson
ertr1...@student.uu.se
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: why newline scape sequence does not work in Freebsd's bash

2011-12-30 Thread Dan Nelson
In the last episode (Dec 31), Erik Trulsson said:
 On Fri, Dec 30, 2011 at 06:47:45PM -0800, Edward Martinez wrote:
  On 12/30/11 17:06, ???  wrote:
   I used ' singe quotes, so double quotes is:
  
   $ FRUIT_BASKET=apples oranges pears
   $ echo -e My fruit basket contains: \n $FRUIT_BASKET
   My fruit basket contains:
   apples oranges pears
  
  Thanks for the help, it worked. I find it interesting that FreeBSD's
  echo man page does not mention the -e option is needed to enable
  backslash escapes.  I remembered why it worked on linux is because i
  created an echo alias with the -e option.  So i will do the same for
  FreeBSD.
 
 The echo(1) manpage on FreeBSD doesn't say anything about '-e' because
 that version of echo doesn't have such an option.  The echo you were
 actually using is the one builtin into bash and is described in the
 bash(1) manpage (including mention of the -e option.)

If you want a command guaranteed to process backslash-escape sequences, use
the printf command, not echo.

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html

It is not possible to use echo portably across all POSIX systems
unless both -n (as the first argument) and escape sequences are
omitted.

The printf utility can be used portably to emulate any of the
traditional behaviors of the echo utility as follows (assuming that
IFS has its standard value or is unset).

New applications are encouraged to use printf instead of echo.

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html

The %b conversion specification is not part of the ISO C standard;
it has been added here as a portable way to process
backslash-escapes expanded in string operands as provided by the
echo utility.  See also the APPLICATION USAGE section of echo for
ways to use printf as a replacement for all of the traditional
versions of the echo utility.

-- 
Dan Nelson
dnel...@allantgroup.com
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


bash can not find most of my commands

2011-02-22 Thread Alokat

Hi,

I have changed my shell from csh to bash ...
But after that I have to call reboot like /sbin/reboot.

How can I change that without changing the shell. :)

my /root/.profile:

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin
export PATH
HOME=/root
export HOME
TERM=${TERM:-cons25}
export TERM
PAGER=more
export PAGER

Regards,
Alokat
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash can not find most of my commands

2011-02-22 Thread Rolf Nielsen

2011-02-22 17:40, Alokat skrev:

Hi,

I have changed my shell from csh to bash ...


Why?
Do you use root as your regular login?


But after that I have to call reboot like /sbin/reboot.

How can I change that without changing the shell. :)

my /root/.profile:

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin

export PATH
HOME=/root
export HOME
TERM=${TERM:-cons25}
export TERM
PAGER=more
export PAGER

Regards,
Alokat
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to
freebsd-questions-unsubscr...@freebsd.org



___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash can not find most of my commands

2011-02-22 Thread Alokat

On 02/22/11 17:44, Rolf Nielsen wrote:

2011-02-22 17:40, Alokat skrev:

Hi,

I have changed my shell from csh to bash ...


Why?
Do you use root as your regular login?


But after that I have to call reboot like /sbin/reboot.

How can I change that without changing the shell. :)

my /root/.profile:

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin 



export PATH
HOME=/root
export HOME
TERM=${TERM:-cons25}
export TERM
PAGER=more
export PAGER

Regards,
Alokat
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to
freebsd-questions-unsubscr...@freebsd.org



___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to 
freebsd-questions-unsubscr...@freebsd.org

It's just for example ... :)
I have a non root login for regular stuff.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash can not find most of my commands

2011-02-22 Thread Paul Macdonald

On 22/02/2011 16:40, Alokat wrote:

Hi,

I have changed my shell from csh to bash ...
But after that I have to call reboot like /sbin/reboot.

How can I change that without changing the shell. :)


don't change your root shell!

csh is in the base system so is safe and will always* work,

bash is a port and gets updated regularly, there's been at least one 
occasion when my bash upgrade failed and i couln't login as root.  very 
frustrating..


I just get used to changing to bash after that, much safer!

Paul.



--
-
Paul Macdonald
IFDNRG Ltd
Web and video hosting
-
t: 0131 5548070
m: 07534206249
e: p...@ifdnrg.com
w: http://www.ifdnrg.com
-
IFDNRG
40 Maritime Street
Edinburgh
EH6 6SA
-


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash can not find most of my commands

2011-02-22 Thread Rolf G Nielsen

2011-02-22 17:47, Alokat skrev:

On 02/22/11 17:44, Rolf Nielsen wrote:

2011-02-22 17:40, Alokat skrev:

Hi,

I have changed my shell from csh to bash ...


Why?
Do you use root as your regular login?


But after that I have to call reboot like /sbin/reboot.

How can I change that without changing the shell. :)

my /root/.profile:

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin


export PATH
HOME=/root
export HOME
TERM=${TERM:-cons25}
export TERM
PAGER=more
export PAGER

Regards,
Alokat
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to
freebsd-questions-unsubscr...@freebsd.org



___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to
freebsd-questions-unsubscr...@freebsd.org

It's just for example ... :)
I have a non root login for regular stuff.


To me the .profile looks ok, and I can't really say why it doesn't work.
However, do not use a shell that's not in the base system for root. Some 
would point security issues, but I don't know much about those when it 
comes to bash, however, if you need to boot into single user, you may 
get into troubles with a shell not in base.



___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to
freebsd-questions-unsubscr...@freebsd.org



___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash can not find most of my commands

2011-02-22 Thread Alokat

On 02/22/11 17:49, Paul Macdonald wrote:

On 22/02/2011 16:40, Alokat wrote:

Hi,

I have changed my shell from csh to bash ...
But after that I have to call reboot like /sbin/reboot.

How can I change that without changing the shell. :)


don't change your root shell!

csh is in the base system so is safe and will always* work,

bash is a port and gets updated regularly, there's been at least one 
occasion when my bash upgrade failed and i couln't login as root.  
very frustrating..


I just get used to changing to bash after that, much safer!

Paul.




Paul has satisfied me. I have changed back to csh.

Thank for help.

Regards,
alokat
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash can not find most of my commands

2011-02-22 Thread Randy Ramsdell

Alokat wrote:

On 02/22/11 17:49, Paul Macdonald wrote:

On 22/02/2011 16:40, Alokat wrote:

Hi,

I have changed my shell from csh to bash ...
But after that I have to call reboot like /sbin/reboot.

How can I change that without changing the shell. :)


don't change your root shell!

csh is in the base system so is safe and will always* work,

bash is a port and gets updated regularly, there's been at least one 
occasion when my bash upgrade failed and i couln't login as root.  
very frustrating..


I just get used to changing to bash after that, much safer!

Paul.




Paul has satisfied me. I have changed back to csh.

Thank for help.

Regards,
alokat



And if you use bash after login or anytime, your original problem remains.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash can not find most of my commands

2011-02-22 Thread Jason Helfman

On Tue, Feb 22, 2011 at 12:08:30PM -0500, Randy Ramsdell thus spake:

Alokat wrote:

On 02/22/11 17:49, Paul Macdonald wrote:

On 22/02/2011 16:40, Alokat wrote:

Hi,

I have changed my shell from csh to bash ...
But after that I have to call reboot like /sbin/reboot.

How can I change that without changing the shell. :)


don't change your root shell!

csh is in the base system so is safe and will always* work,

bash is a port and gets updated regularly, there's been at least one
occasion when my bash upgrade failed and i couln't login as root.
very frustrating..

I just get used to changing to bash after that, much safer!

Paul.




Paul has satisfied me. I have changed back to csh.

Thank for help.

Regards,
alokat



And if you use bash after login or anytime, your original problem remains.


This has to do with your path, and it is known good practice to use full
paths, as well.

-jgh
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash can not find most of my commands

2011-02-22 Thread Lars Eighner

On Tue, 22 Feb 2011, Alokat wrote:


Paul has satisfied me. I have changed back to csh.


If you want to run as root and use bash, well, that is what the user toor is
for (examine master.passwd -- use vipw to edit master.passwd to enter a
password for toor and the path to bash for toor, but set EDITOR first if you
are not comfortable with vi).  If you activate toor, you can log in as toor,
use bash, and yet you are root (try whoami as toor).  This preserves the
root login for emergencies when /usr may not be mounted.

--
Lars Eighner
http://www.larseighner.com/index.html
8800 N IH35 APT 1191 AUSTIN TX 78753-5266

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash can not find most of my commands

2011-02-22 Thread Warren Block

On Tue, 22 Feb 2011, Paul Macdonald wrote:


On 22/02/2011 16:40, Alokat wrote:

Hi,

I have changed my shell from csh to bash ...
But after that I have to call reboot like /sbin/reboot.

How can I change that without changing the shell. :)


don't change your root shell!

csh is in the base system so is safe and will always* work,

bash is a port and gets updated regularly, there's been at least one occasion 
when my bash upgrade failed and i couln't login as root.  very frustrating..


I just get used to changing to bash after that, much safer!


Consider running bash from .cshrc.  Less breakable than changing root's 
shell, but still kind of automatic.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash can not find most of my commands

2011-02-22 Thread Chad Perrin
On Tue, Feb 22, 2011 at 05:58:22PM +0100, Alokat wrote:

 Paul has satisfied me. I have changed back to csh.

Your system should have a toor account as well.  It is just a second
root account, whose essential purpose is to provide a root account that
you can fiddle with to your heart's content without endangering the main
root account.  Note that the toor account can break things on the system
just as much as the root account; if you break the toor account itself,
though, you still have access to the main root account to get yourself
out of trouble.

Thus, if you *really* want a superuser account with bash as its default
shell, you can always use toor for that purpose.  I don't much see the
point in setting a superuser account to use bash anyway -- or any other
account, really -- but the option is there if you must have it.  Just
don't change the shell for the root account itself that way; it's bad for
you, with lots of fatty calories, preservatives, artificial sweeteners,
and other stuff your body should not be ingesting on a regular basis.

-- 
Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]


pgpQg5oXnDcAV.pgp
Description: PGP signature


Re: bash can not find most of my commands

2011-02-22 Thread David Brodbeck
On Tue, Feb 22, 2011 at 9:53 AM, Chad Perrin per...@apotheon.com wrote:
 Thus, if you *really* want a superuser account with bash as its default
 shell, you can always use toor for that purpose.  I don't much see the
 point in setting a superuser account to use bash anyway -- or any other
 account, really -- but the option is there if you must have it.

It turns out auto-completion with hinting and command history
searching are pretty addictive if you're used to having them. :)

Personally, I usually just use sudo, or run bash as my first command
after gaining root powers.  But it's very interesting to finally find
out what toor is for.  I'd always wondered.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash can not find most of my commands

2011-02-22 Thread Chad Perrin
On Tue, Feb 22, 2011 at 10:07:54AM -0800, David Brodbeck wrote:
 On Tue, Feb 22, 2011 at 9:53 AM, Chad Perrin per...@apotheon.com wrote:
 
 It turns out auto-completion with hinting and command history
 searching are pretty addictive if you're used to having them. :)

I have auto-completion, and I know my environment well enough that hints
aren't generally helpful.


 
 Personally, I usually just use sudo, or run bash as my first command
 after gaining root powers.  But it's very interesting to finally find
 out what toor is for.  I'd always wondered.

Glad to be of some help.

Just do us all a favor; don't write code in bash.  Use Bourne shell (sh,
not bash), or a real programming language (Perl, Ruby, Python,
whatever).  The bash option essentially tries to capture the power of
such real languages, but does a very bad job of it -- and gives up the
nigh-universal portability across Unix-like systems to do so.  It's the
worst of all worlds.

-- 
Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]


pgpwBJdOKArNp.pgp
Description: PGP signature


Re: bash can not find most of my commands

2011-02-22 Thread David Brodbeck
On Tue, Feb 22, 2011 at 12:39 PM, Chad Perrin per...@apotheon.com wrote:
 Just do us all a favor; don't write code in bash.

Yeah, I try to avoid bash-specific syntax unless it's for one-off
scripts.  csh suffers the same kinds of problems; I only write csh
code under extreme duress, like when forced to maintain the
system-wide csh.login script. ;)
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash can not find most of my commands

2011-02-22 Thread Chad Perrin
On Tue, Feb 22, 2011 at 01:10:20PM -0800, David Brodbeck wrote:
 
 Yeah, I try to avoid bash-specific syntax unless it's for one-off
 scripts.  csh suffers the same kinds of problems; I only write csh
 code under extreme duress, like when forced to maintain the
 system-wide csh.login script. ;)

I often use tcsh as an interactive shell, but I do not use it for shell
scripts.

-- 
Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]


pgpW4w3idg6aw.pgp
Description: PGP signature


Re: bash can not find most of my commands

2011-02-22 Thread Chip Camden
Quoth David Brodbeck on Tuesday, 22 February 2011:
 On Tue, Feb 22, 2011 at 12:39 PM, Chad Perrin per...@apotheon.com wrote:
  Just do us all a favor; don't write code in bash.

What's with all the bash bashing?

Sorry, couldn't resist.

 
 Yeah, I try to avoid bash-specific syntax unless it's for one-off
 scripts.  csh suffers the same kinds of problems; I only write csh
 code under extreme duress, like when forced to maintain the
 system-wide csh.login script. ;)

At least sh scripts will execute correctly under bash -- they don't
always under csh/tcsh.

I like zsh for a command-line shell, but when writing scripts for general
usage I stick with the sh-compatibile subset of capabilities, and I enforce
that on myself with the #!/bin/sh shebang.  If I need more than what that
can gracefully do, I usually run to the arms of Ruby.

-- 
Sterling (Chip) Camden | sterl...@camdensoftware.com | 2048D/3A978E4F
http://chipsquips.com  | http://camdensoftware.com   | http://chipstips.com


pgpISYvMSTcjg.pgp
Description: PGP signature


bash increment in a given way

2010-12-11 Thread S Mathias
It's ok, that i can use this, when i want an incrementing sequence, in a given 
way:

# {START..END..INCREMENT}
$ for i in {0..10..2}; do echo Welcome $i times; done
Welcome 0 times
Welcome 2 times
Welcome 4 times
Welcome 6 times
Welcome 8 times
Welcome 10 times
$

but what's the magic for this? :

$ MAGIC; do echo Welcome $i times; done
Welcome 0 times
Welcome 1 times
Welcome 4 times
Welcome 5 times
Welcome 8 times
Welcome 9 times
$

thanks:\



  
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash increment in a given way

2010-12-11 Thread Samuel Martín Moro
something like that?
for i in `seq 1 20 | awk 'BEGIN{n=0; max=4; avg=max/2}{if (n=avg) {print
$0;} n++; if (n=max) {n=0;} }'`
do
echo welcome $i times
done



On Sat, Dec 11, 2010 at 3:34 PM, S Mathias smathias1...@yahoo.com wrote:

 , that i can use this, when i want




-- 
Samuel Martín Moro
{EPITECH.} tek5
CamTrace S.A.S
  (+033) 1 41 38 37 60
  1 Allée de la Venelle
  92150 Suresnes
  FRANCE

Nobody wants to say how this works.
  Maybe nobody knows ...
  Xorg.conf(5)
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash increment in a given way

2010-12-11 Thread Samuel Martín Moro
with seq starting with 0, to fit your example...

On Sat, Dec 11, 2010 at 5:34 PM, Samuel Martín Moro faus...@gmail.comwrote:

 something like that?
 for i in `seq 1 20 | awk 'BEGIN{n=0; max=4; avg=max/2}{if (n=avg) {print
 $0;} n++; if (n=max) {n=0;} }'`
 do
 echo welcome $i times
 done



 On Sat, Dec 11, 2010 at 3:34 PM, S Mathias smathias1...@yahoo.com wrote:

 , that i can use this, when i want




 --
 Samuel Martín Moro
 {EPITECH.} tek5
 CamTrace S.A.S
   (+033) 1 41 38 37 60
   1 Allée de la Venelle
   92150 Suresnes
   FRANCE

 Nobody wants to say how this works.
   Maybe nobody knows ...
   Xorg.conf(5)




-- 
Samuel Martín Moro
{EPITECH.} tek5
CamTrace S.A.S
  (+033) 1 41 38 37 60
  1 Allée de la Venelle
  92150 Suresnes
  FRANCE

Nobody wants to say how this works.
  Maybe nobody knows ...
  Xorg.conf(5)
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash increment in a given way

2010-12-11 Thread Samuel Martín Moro
also... if (navg) ... sorry for the sp am...

On Sat, Dec 11, 2010 at 5:36 PM, Samuel Martín Moro faus...@gmail.comwrote:

 with seq starting with 0, to fit your example...

 On Sat, Dec 11, 2010 at 5:34 PM, Samuel Martín Moro faus...@gmail.comwrote:

 something like that?
 for i in `seq 1 20 | awk 'BEGIN{n=0; max=4; avg=max/2}{if (n=avg) {print
 $0;} n++; if (n=max) {n=0;} }'`
 do
 echo welcome $i times
 done



 On Sat, Dec 11, 2010 at 3:34 PM, S Mathias smathias1...@yahoo.comwrote:

 , that i can use this, when i want




 --
 Samuel Martín Moro
 {EPITECH.} tek5
 CamTrace S.A.S
   (+033) 1 41 38 37 60
   1 Allée de la Venelle
   92150 Suresnes
   FRANCE

 Nobody wants to say how this works.
   Maybe nobody knows ...
   Xorg.conf(5)




 --
 Samuel Martín Moro
 {EPITECH.} tek5
 CamTrace S.A.S
   (+033) 1 41 38 37 60
   1 Allée de la Venelle
   92150 Suresnes
   FRANCE

 Nobody wants to say how this works.
   Maybe nobody knows ...
   Xorg.conf(5)




-- 
Samuel Martín Moro
{EPITECH.} tek5
CamTrace S.A.S
  (+033) 1 41 38 37 60
  1 Allée de la Venelle
  92150 Suresnes
  FRANCE

Nobody wants to say how this works.
  Maybe nobody knows ...
  Xorg.conf(5)
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash increment in a given way

2010-12-11 Thread Charlie Kester

On Sat 11 Dec 2010 at 06:34:20 PST S Mathias wrote:

It's ok, that i can use this, when i want an incrementing sequence, in a given 
way:

# {START..END..INCREMENT}
$ for i in {0..10..2}; do echo Welcome $i times; done
Welcome 0 times
Welcome 2 times
Welcome 4 times
Welcome 6 times
Welcome 8 times
Welcome 10 times
$

but what's the magic for this? :

$ MAGIC; do echo Welcome $i times; done
Welcome 0 times
Welcome 1 times
Welcome 4 times
Welcome 5 times
Welcome 8 times
Welcome 9 times
$


man jot(1)
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash increment in a given way

2010-12-11 Thread Charlie Kester

On Sat 11 Dec 2010 at 09:57:08 PST Charlie Kester wrote:

On Sat 11 Dec 2010 at 06:34:20 PST S Mathias wrote:

It's ok, that i can use this, when i want an incrementing sequence, in a given 
way:

# {START..END..INCREMENT}
$ for i in {0..10..2}; do echo Welcome $i times; done
Welcome 0 times
Welcome 2 times
Welcome 4 times
Welcome 6 times
Welcome 8 times
Welcome 10 times
$

but what's the magic for this? :

$ MAGIC; do echo Welcome $i times; done
Welcome 0 times
Welcome 1 times
Welcome 4 times
Welcome 5 times
Welcome 8 times
Welcome 9 times
$


man jot(1)


Or maybe not.  
It's still morning here and the coffee hasn't kicked in yet.  

I usually reach for jot when constructing loops that look like yours, 
but on second glance I'm not sure it can produce the output you want.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


bash command line - can not type c char (not echoed)

2010-12-03 Thread JB
Hi,

this happens both in console and gnome xterm.
No problem when change from bash prompt to sh subshell.
There are packages, no ports on my system.

$ uname -r
8.1-RELEASE
$ env |grep -i shell
SHELL=/usr/local/bin/bash
$ ls /var/db/pkg/bash-4.1.7/
No readline lib present.

JB


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


bash command line - can not type c char (not echoed) [SOLVED]

2010-12-03 Thread J B
my .bashrc had some bind commands and that probably had something to do with it.
I relogged in and all is OK.
JB
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


console and bash - how to get Delete key working properly ?

2010-12-03 Thread J B
Hi,
I searched BSD docs and Google for answers, but none of them works.

By working properly I mean for Del key to delete char under the cursor
and not the previous one.

It works in gnome xterm, but not in console.

It works in sh with config hint from FreeBSD handbook:
  bind ^? ed-delete-next-char # for console
  bind ^[[3~ ed-delete-next-char # for xterm
but not in bash (with or w/o the hint).

Having readline lib installed does not make any difference as well.

$ uname -r
8.1-RELEASE
$ env |grep -i shell
SHELL=/usr/local/bin/bash
$ ls /var/db/pkg/bash-4.1.7/
No readline lib installed.

JB
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash command line - can not type c char (not echoed)

2010-12-03 Thread Chris Rees
Glad you solved it.

Are you aware that packages and ports are identical once installed?

Chris



Sorry for top-posting, Android won't let me quote, but K-9 can't yet do
threading.
On 3 Dec 2010 11:35, JB jb.1234a...@gmail.com wrote:
 Hi,

 this happens both in console and gnome xterm.
 No problem when change from bash prompt to sh subshell.
 There are packages, no ports on my system.

 $ uname -r
 8.1-RELEASE
 $ env |grep -i shell
 SHELL=/usr/local/bin/bash
 $ ls /var/db/pkg/bash-4.1.7/
 No readline lib present.

 JB


 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to 
freebsd-questions-unsubscr...@freebsd.org
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash command line - can not type quot; cquot; char (not echoed)

2010-12-03 Thread JB
Chris Rees utisoft at gmail.com writes:

 
 Glad you solved it.
 
 Are you aware that packages and ports are identical once installed?
 ... 
  ...
  There are packages, no ports on my system.
 

Yes, I am.
I made a statement that looks incomprehensible -:)

JB
 




___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Multiple mount_smbfs commands fail in bash script

2010-09-02 Thread Bernard Scharp
Hi all,

I'm having some problems with a bash script.

It's a backup script that periodically checks if a list of systems is
online, and if so, uses samba to mount a specified list of shares,
rsyncs them to a local directory and unmounts again.

This used to run fine till a few months ago (I don't know what the
trigger was that caused them to first fail).

Now, when the script is run, it gives the following error when mounting
the shares:

mount_smbfs: can't get handle to requester (no /dev/nsmb* device)

Which is strange, as there are (by last count) 1170 /dev/nsmb* devices
in /dev/ (is that normal?)

Searching the internet, FreeBSD and Samba mailing lists gave me no
recent info, and the old info wasn't helpful.

I've narrowed it down to the point where I think it's caused by one
process trying to open two (or more) shares at the same time. (a simple
script mounting two shares gives the same error).

I can mount the shares from the command line without problems, it's only
in the bash script it gives me problems.

~/.nsmbrc and /etc/nsmb.conf are correct, smbd, nmbd and winbindd are
running. The system is FreeBSD 8.0 Stable.

Anyone got any suggestions?

Regards,
Bernard
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Multiple mount_smbfs commands fail in bash script

2010-09-02 Thread Jerry
On Thu, 02 Sep 2010 10:24:05 +0200
Bernard Scharp freebsd-questi...@itsacon.net articulated:

 Hi all,
 
 I'm having some problems with a bash script.
 
 It's a backup script that periodically checks if a list of systems is
 online, and if so, uses samba to mount a specified list of shares,
 rsyncs them to a local directory and unmounts again.
 
 This used to run fine till a few months ago (I don't know what the
 trigger was that caused them to first fail).
 
 Now, when the script is run, it gives the following error when
 mounting the shares:
 
 mount_smbfs: can't get handle to requester (no /dev/nsmb* device)
 
 Which is strange, as there are (by last count) 1170 /dev/nsmb* devices
 in /dev/ (is that normal?)
 
 Searching the internet, FreeBSD and Samba mailing lists gave me no
 recent info, and the old info wasn't helpful.
 
 I've narrowed it down to the point where I think it's caused by one
 process trying to open two (or more) shares at the same time. (a
 simple script mounting two shares gives the same error).
 
 I can mount the shares from the command line without problems, it's
 only in the bash script it gives me problems.
 
 ~/.nsmbrc and /etc/nsmb.conf are correct, smbd, nmbd and winbindd are
 running. The system is FreeBSD 8.0 Stable.
 
 Anyone got any suggestions?

Could you post the script? Anything else would be pure guess work. You
also might consider posting this on the BASH mail forum:

bug-b...@gnu.org

although you might have to subscribe first:

http://lists.gnu.org/mailman/listinfo/bug-bash

-- 
Jerry ✌
freebsd.u...@seibercom.net

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.
__

Vital papers will demonstrate their vitality by spontaneously moving
from where you left them to where you can't find them.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Multiple mount_smbfs commands fail in bash script

2010-09-02 Thread Bernard Scharp

 
 Could you post the script? Anything else would be pure guess work. You

Well, I can recreate it with something as simple as:

#!/usr/local/bin/bash
mount_smbfs //u...@remotehost/share1/ /tmp/mnt/
mount_smbfs //u...@remotehost/share2/ /tmp/mnt2/


 also might consider posting this on the BASH mail forum:
 
   bug-b...@gnu.org
 
 although you might have to subscribe first:
 
   http://lists.gnu.org/mailman/listinfo/bug-bash
 

I'l look into that, (though I doubt this is a bash issue).

Thanks!
Bernard

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Multiple mount_smbfs commands fail in bash script

2010-09-02 Thread Polytropon
On Thu, 02 Sep 2010 14:02:35 +0200, Bernard Scharp 
freebsd-questi...@itsacon.net wrote:
 
  
  Could you post the script? Anything else would be pure guess work. You
 
 Well, I can recreate it with something as simple as:
 
 #!/usr/local/bin/bash
 mount_smbfs //u...@remotehost/share1/ /tmp/mnt/
 mount_smbfs //u...@remotehost/share2/ /tmp/mnt2/

Excuse me, it may just be a stupid question... but... why do
you use bash for this purpose? Do you require any special
bash feature that cannot be done using the standard shell,
sh? I often see the urge to use bash for scripting as a
typical Linuxism, which is usually non-portable (if that
was your goal). FreeBSD's standard scripting shell is sh,
so why not use it until you reach the ends of its functionality?



Just a guess, regarding your initial question, as I don't have
experience with Windows related things: Did you have the
chance to monitor correct operations of your script in the
past? Did the mound and umount (!) calls work properly? Have
you checked your commands running them in the standard dialog
shell (csh)? I assume you're running them as root (or at least
with sufficient permissions), so I don't think the problem
is there, as the error message

mount_smbfs: can't get handle to requester (no /dev/nsmb* device)

doesn't look like refering to that problem.

The error message originates from /usr/src/contrib/smbfs/lib/smb/ctx.c;
having a look around, and remembering that you said

 [...] there are (by last count) 1170 /dev/nsmb* devices
 in /dev/ (is that normal?)

I found smb_ctx_gethandle() near line 600 (version 7 OS here):

/*
 * well, no clone capabilities available - we have to scan
 * all devices in order to get free one
 */
 for (i = 0; i  1024; i++) {
 snprintf(buf, sizeof(buf), /dev/%s%d, NSMB_NAME, i);
 fd = open(buf, O_RDWR);
 if (fd = 0) {
ctx-ct_fd = fd;
return 0;
 }
 }

The limit seems to be 1024, if I read that correctly - allthough
I'm considered a C hacker, I'm no OS-level C hacker. :-)

Afterwards, smb_ctx_lookup() fails and gives the error message
mentioned earlier.

Remove the /dev/nsmb* devices and try again. Make sure no other
SMB stuff is currently mounted, just to be sure, as I don't have
any idea what could fail.




-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Multiple mount_smbfs commands fail in bash script

2010-09-02 Thread Bernard Scharp
On 02/09/2010 15:29, Polytropon wrote:
 On Thu, 02 Sep 2010 14:02:35 +0200, Bernard Scharp 
 freebsd-questi...@itsacon.net wrote:


 Could you post the script? Anything else would be pure guess work. You

 Well, I can recreate it with something as simple as:

 #!/usr/local/bin/bash
 mount_smbfs //u...@remotehost/share1/ /tmp/mnt/
 mount_smbfs //u...@remotehost/share2/ /tmp/mnt2/
 
 Excuse me, it may just be a stupid question... but... why do
 you use bash for this purpose? Do you require any special
 bash feature that cannot be done using the standard shell,
 sh? I often see the urge to use bash for scripting as a
 typical Linuxism, which is usually non-portable (if that
 was your goal). FreeBSD's standard scripting shell is sh,
 so why not use it until you reach the ends of its functionality?

The script above is a (heavily) reduced version, used to isolate the
problem. The real script is much longer, and uses a bunch of logic to
walk through a list of different systems (each with their own lists of
shares, loaded from external files), taking snapshots of the previous
backup, logging which systems were backed up, rolling back operations if
a backup fails, etc.

 Just a guess, regarding your initial question, as I don't have
 experience with Windows related things: Did you have the
 chance to monitor correct operations of your script in the
 past? Did the mound and umount (!) calls work properly? Have
 you checked your commands running them in the standard dialog
 shell (csh)? I assume you're running them as root (or at least
 with sufficient permissions), so I don't think the problem
 is there, as the error message
 
 mount_smbfs: can't get handle to requester (no /dev/nsmb* device)
 
 doesn't look like refering to that problem.

I am running it as root, and I just tried running the (test)script
(without the bash reference) under a csh shell, and got the same error,
so it's not a bash problem.

As for monitoring the operations of the script, it has worked fine
before (for several years), so I'm pretty sure the code is correct.

 
 The error message originates from /usr/src/contrib/smbfs/lib/smb/ctx.c;
 having a look around, and remembering that you said
 
 [...] there are (by last count) 1170 /dev/nsmb* devices
 in /dev/ (is that normal?)
 
 I found smb_ctx_gethandle() near line 600 (version 7 OS here):
 
 /*
  * well, no clone capabilities available - we have to scan
  * all devices in order to get free one
  */
  for (i = 0; i  1024; i++) {
  snprintf(buf, sizeof(buf), /dev/%s%d, NSMB_NAME, i);
  fd = open(buf, O_RDWR);
  if (fd = 0) {
 ctx-ct_fd = fd;
 return 0;
  }
  }
 
 The limit seems to be 1024, if I read that correctly - allthough
 I'm considered a C hacker, I'm no OS-level C hacker. :-)

Neither am I. Hadn't even thought of grepping in /usr/src for the error
message :-)

 
 Afterwards, smb_ctx_lookup() fails and gives the error message
 mentioned earlier.
 
 Remove the /dev/nsmb* devices and try again. Make sure no other
 SMB stuff is currently mounted, just to be sure, as I don't have
 any idea what could fail.
 

Can I just `rm /dev/nsmbX` them? (messing in /dev/ is a level of FreeBSD
I'm not familiar with)

Thanks for all your help!

Bernard
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Multiple mount_smbfs commands fail in bash script

2010-09-02 Thread Polytropon
On Thu, 02 Sep 2010 15:52:25 +0200, Bernard Scharp 
freebsd-questi...@itsacon.net wrote:
 Neither am I. Hadn't even thought of grepping in /usr/src for the error
 message :-)

It's often a good starting point to see where problems might
be caused from.



 Can I just `rm /dev/nsmbX` them? (messing in /dev/ is a level of FreeBSD
 I'm not familiar with)

Yes, I would guess so. The content of /dev/ is dynamically generated
since FreeBSD 5, if I remember correctly. As the nsmb nodes don't
seem to be in use any longer, it would be no problem to remove
them. The mount_smbfs program will generate them if needed.

Just as an addition: After your script successfully performed the
operations needing the mounted SMB shares, it could remove the
corresponding device files.

Still, this looks like a bug to me, a can't image anybody needs more
than 1024 of them kind of bug. I would have imagined that IF a
program needs files in a temporary way, it removes them after use.

Just to be sure, unmount all SMB related things, as I can't predict
what would happen if a nsmb device disappears when in use.




-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Bash Script Help - File Names With Spaces

2010-08-17 Thread Drew Tomlinson
I have a collection of yearly top 100 Billboard mp3s in this format (all 
one line - sorry if it wraps):


/archive/Multimedia/Audio/Music/Billboard Top USA Singles/1980-028 Kenny 
Loggins - This Is It.mp3


I want to create symbolic links to the top 30 in 1966-1969 in another 
directory for easy migration to a flash card. Thus I invoked 'find' to 
get a list (again, all one line):


find -E /archive/Multimedia/Audio/Music/Billboard Top USA Singles 
-regex '.*19[6-9][0-9]-0[0-2][0-9].*'


(OK, I know this will only return the top 29)

'find' returns the complete filename as above:

/archive/Multimedia/Audio/Music/Billboard Top USA Singles/1980-028 Kenny 
Loggins - This Is It.mp3


Then I attempt to use 'basename' to extract the file name to a variable 
which I can later pass to 'ln'.  This seems to work:


basename /archive/Multimedia/Audio/Music/Billboard Top USA 
Singles/1980-028 Kenny Loggins - This Is It.mp3


returns (all one line):

1980-028 Kenny Loggins - This Is It.mp3

which is what I would expect.  However using it with 'find' give me this 
type of unexpected result:


for i in `find -E /archive/Multimedia/Audio/Music/Billboard Top USA 
Singles -regex '.*19[6-9][0-9]-0[1-2][0-9].*'`; do basename ${i};done


1980-028
Kenny
Loggins
-
This
Is
It.mp3

Why is this different? And more importantly, how can I capture the file 
name to $i?


Thanks,

Drew

--
Like card tricks?

Visit The Alchemist's Warehouse to
learn card magic secrets for free!

http://alchemistswarehouse.com

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Bash Script Help - File Names With Spaces

2010-08-17 Thread Chip Camden
Quoth Drew Tomlinson on Tuesday, 17 August 2010:
 I have a collection of yearly top 100 Billboard mp3s in this format (all 
 one line - sorry if it wraps):
 
 /archive/Multimedia/Audio/Music/Billboard Top USA Singles/1980-028 Kenny 
 Loggins - This Is It.mp3
 
 I want to create symbolic links to the top 30 in 1966-1969 in another 
 directory for easy migration to a flash card. Thus I invoked 'find' to 
 get a list (again, all one line):
 
 find -E /archive/Multimedia/Audio/Music/Billboard Top USA Singles 
 -regex '.*19[6-9][0-9]-0[0-2][0-9].*'
 
 (OK, I know this will only return the top 29)
 
 'find' returns the complete filename as above:
 
 /archive/Multimedia/Audio/Music/Billboard Top USA Singles/1980-028 Kenny 
 Loggins - This Is It.mp3
 
 Then I attempt to use 'basename' to extract the file name to a variable 
 which I can later pass to 'ln'.  This seems to work:
 
 basename /archive/Multimedia/Audio/Music/Billboard Top USA 
 Singles/1980-028 Kenny Loggins - This Is It.mp3
 
 returns (all one line):
 
 1980-028 Kenny Loggins - This Is It.mp3
 
 which is what I would expect.  However using it with 'find' give me this 
 type of unexpected result:
 
 for i in `find -E /archive/Multimedia/Audio/Music/Billboard Top USA 
 Singles -regex '.*19[6-9][0-9]-0[1-2][0-9].*'`; do basename ${i};done
 
 1980-028
 Kenny
 Loggins
 -
 This
 Is
 It.mp3
 
 Why is this different? And more importantly, how can I capture the file 
 name to $i?

Try:

find -E ... | while read i; do; basename $i; done

When using back-ticks, all the output gets appended together,
space-separated.  Then 'for' can't tell the difference between a space in
a filename and a delimiter.  Using 'read' instead preserves line
boundaries.

 
 Thanks,
 
 Drew
 
 -- 
 Like card tricks?
 
 Visit The Alchemist's Warehouse to
 learn card magic secrets for free!
 
 http://alchemistswarehouse.com
 
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org

-- 
Sterling (Chip) Camden| sterl...@camdensoftware.com | 2048D/3A978E4F
http://camdensoftware.com | http://chipstips.com| http://chipsquips.com


pgpCHrUZ30LlM.pgp
Description: PGP signature


Re: Bash Script Help - File Names With Spaces -- SOLVED

2010-08-17 Thread Drew Tomlinson

On 8/17/2010 7:47 AM, Drew Tomlinson wrote:
I have a collection of yearly top 100 Billboard mp3s in this format 
(all one line - sorry if it wraps):


/archive/Multimedia/Audio/Music/Billboard Top USA Singles/1980-028 
Kenny Loggins - This Is It.mp3


I want to create symbolic links to the top 30 in 1966-1969 in another 
directory for easy migration to a flash card. Thus I invoked 'find' to 
get a list (again, all one line):


find -E /archive/Multimedia/Audio/Music/Billboard Top USA Singles 
-regex '.*19[6-9][0-9]-0[0-2][0-9].*'


(OK, I know this will only return the top 29)

'find' returns the complete filename as above:

/archive/Multimedia/Audio/Music/Billboard Top USA Singles/1980-028 
Kenny Loggins - This Is It.mp3


Then I attempt to use 'basename' to extract the file name to a 
variable which I can later pass to 'ln'.  This seems to work:


basename /archive/Multimedia/Audio/Music/Billboard Top USA 
Singles/1980-028 Kenny Loggins - This Is It.mp3


returns (all one line):

1980-028 Kenny Loggins - This Is It.mp3

which is what I would expect.  However using it with 'find' give me 
this type of unexpected result:


for i in `find -E /archive/Multimedia/Audio/Music/Billboard Top USA 
Singles -regex '.*19[6-9][0-9]-0[1-2][0-9].*'`; do basename ${i};done


1980-028
Kenny
Loggins
-
This
Is
It.mp3

Why is this different? And more importantly, how can I capture the 
file name to $i?


It finally occurred to me that I needed the shell to see a new line as 
the delimiter and not whitespace. Then a simple search revealed my answer:


O=$IFS
IFS=$(echo -en \n\b)
do stuff
IFS=$O

Sorry for the noise.

Drew

--
Like card tricks?

Visit The Alchemist's Warehouse to
learn card magic secrets for free!

http://alchemistswarehouse.com

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Bash Script Help - File Names With Spaces

2010-08-17 Thread Drew Tomlinson

On 8/17/2010 8:22 AM, Chip Camden wrote:

Quoth Drew Tomlinson on Tuesday, 17 August 2010:
   

I have a collection of yearly top 100 Billboard mp3s in this format (all
one line - sorry if it wraps):

/archive/Multimedia/Audio/Music/Billboard Top USA Singles/1980-028 Kenny
Loggins - This Is It.mp3

I want to create symbolic links to the top 30 in 1966-1969 in another
directory for easy migration to a flash card. Thus I invoked 'find' to
get a list (again, all one line):

find -E /archive/Multimedia/Audio/Music/Billboard Top USA Singles
-regex '.*19[6-9][0-9]-0[0-2][0-9].*'

(OK, I know this will only return the top 29)

'find' returns the complete filename as above:

/archive/Multimedia/Audio/Music/Billboard Top USA Singles/1980-028 Kenny
Loggins - This Is It.mp3

Then I attempt to use 'basename' to extract the file name to a variable
which I can later pass to 'ln'.  This seems to work:

basename /archive/Multimedia/Audio/Music/Billboard Top USA
Singles/1980-028 Kenny Loggins - This Is It.mp3

returns (all one line):

1980-028 Kenny Loggins - This Is It.mp3

which is what I would expect.  However using it with 'find' give me this
type of unexpected result:

for i in `find -E /archive/Multimedia/Audio/Music/Billboard Top USA
Singles -regex '.*19[6-9][0-9]-0[1-2][0-9].*'`; do basename ${i};done

1980-028
Kenny
Loggins
-
This
Is
It.mp3

Why is this different? And more importantly, how can I capture the file
name to $i?
 

Try:

find -E ... | while read i; do; basename $i; done

When using back-ticks, all the output gets appended together,
space-separated.  Then 'for' can't tell the difference between a space in
a filename and a delimiter.  Using 'read' instead preserves line
boundaries.


Thanks for your reply.  I like this better than manipulating $IFS 
because then I don't have to set it back.


Cheers,

Drew

--
Like card tricks?

Visit The Alchemist's Warehouse to
learn card magic secrets for free!

http://alchemistswarehouse.com

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Bash Script Help - File Names With Spaces

2010-08-17 Thread Timm Wimmers
Am Dienstag, den 17.08.2010, 08:22 -0700 schrieb Chip Camden:
 find -E ... | while read i; do; basename $i; done

The semicolon behind do isn't necessary.

-- 
Timm

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Bash Script Help - File Names With Spaces

2010-08-17 Thread Karl Vogel
 On Tue, 17 Aug 2010 07:47:25 -0700, 
 Drew Tomlinson d...@mykitchentable.net said:

D Then I attempt to use 'basename' to extract the file name to a variable
D which I can later pass to 'ln'.  This seems to work:
D   basename /archive/Multimedia/Audio/Music/Billboard Top USA
D   Singles/1980-028 Kenny Loggins - This Is It.mp3

   This is a subset of a larger problem: getting the last field from a set
   of delimited records which may not all have the same number of fields.

   I've used this when I needed basenames for ~500,000 files:
 find . regex-or-print-or-whatever | rev | cut -f1 -d/ | rev

   For dirnames:
 find . regex-or-print-or-whatever | rev | cut -f2- -d/ | rev | sort -u

-- 
Karl Vogel  I don't speak for the USAF or my company

When I'm feeling down, I like to whistle.  It makes the
neighbor's dog run to the end of his chain and gag himself.--unknown
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Bash Script Help - File Names With Spaces -- SOLVED

2010-08-17 Thread Anonymous
Drew Tomlinson d...@mykitchentable.net writes:

 It finally occurred to me that I needed the shell to see a new line as
 the delimiter and not whitespace. Then a simple search revealed my
 answer:

 O=$IFS
 IFS=$(echo -en \n\b)
 do stuff
 IFS=$O

Old IFS value can be preserved by using `local' keyword or (...) braces, too.
It's a bit better than polluting global scope with temporary variable.

  $ echo -n $IFS | (vis -w; echo)
  \040\^I\^J

  $ for i in $(find . -type f); do echo $i; done
  ./My
  Long
  File
  Name
  ./Another
  File

  $ f() { local IFS=; eval $@; }
  $ f 'for i in $(find . -type f); do echo $i; done'
  ./My Long File Name
  ./Another File

  $ (IFS=; for i in $(find . -type f); do echo $i; done)
  ./My Long File Name
  ./Another File

  $ echo -n $IFS | (vis -w; echo)
  \040\^I\^J
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Bash logging: two questions

2010-07-21 Thread jimbob palmer
Hello,

I would like to run a bash script but to log output and exit codes.
Essentially I would like to run the script with bash -x, but for that
output to the log to go to a file, and the normal output as from
running a normal script to go to the terminal.

That's my first question :)

My second question is about history. Bash has a -h option to remember
the location of commands as they are looked up. Is it possible for
this to be recorded in the history? e.g. if I run ls, it would record
/bin/ls to the bash history file.

Many thanks.

JB
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Bash logging: two questions

2010-07-21 Thread Anonymous
jimbob palmer jimbobpal...@gmail.com writes:

 Hello,

 I would like to run a bash script but to log output and exit codes.
 Essentially I would like to run the script with bash -x, but for that
 output to the log to go to a file, and the normal output as from
 running a normal script to go to the terminal.

Dunno about bash but in zsh it's easy

  #! /usr/bin/env zsh
  PS4='+%i:%N:%? '
  exec 2trace.log
  set -x

  # here goes the main script
  foo=5
  bar=$(date)
  echo foo=$foo, $bar
  false
  echo

It should work in sh(1) except you'll not see exit values in prompt.

Seems like bash doesn't have tcsh-like features: `%?' and printexitvalue.
I guess you'll have to write your own wrapper to put `$?' into stderr
after each command.

 My second question is about history. Bash has a -h option to remember
 the location of commands as they are looked up. Is it possible for
 this to be recorded in the history? e.g. if I run ls, it would record
 /bin/ls to the bash history file.

If bash has smth like zshaddhistory() it'd be easy...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Switched to Bash and Comparison of Shells

2010-06-14 Thread Dan D Niles
On Fri, 2010-06-11 at 11:46 +0930, Malcolm Kay wrote:
 On Fri, 11 Jun 2010 02:49 am, Dan D Niles wrote:
  I had been using csh/tcsh for 20 years and I just switched to
  bash.  The recent discussion about the differences between the
  shells prompted me to take another look at bash.  I thought
  I'd share my perception of the differences between tcsh and
  bash.
 
 It seems to me that it is a little late in the day to be changing
 to bash. Some well known Linux distributions are beginning to see 
 that some non-posix features of bash can create difficulties. I 
 believe recent releases of Ubuntu use dash as the prefered 
 shell, and it looks as though Debian will be going the same way.
 Dash is supposed to be a modern, faster and cleaner 
 implementation of sh -- if installed through FBSD ports it has 
 the same man page as sh.

For an interactive shell, it doesn't really matter if it has non-POSIX
features or not.  For scripts it is a different story.  If you use
non-POSIX features in a script, it becomes less portable.  I switched my
interactive shell not my scripting shell. 

The problem with Linux distros is they replaced /bin/sh with bash.  I
imagine that non-POSIX features started to creep into their shell
scripts and they became less portable.   I agree with Linux distros
using a POSIX shell for /bin/sh instead of bash.  Ubuntu has been using
dash as of at least 9.04, BTW.



___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Switched to Bash and Comparison of Shells

2010-06-10 Thread Dan D Niles

I had been using csh/tcsh for 20 years and I just switched to bash.  The
recent discussion about the differences between the shells prompted me
to take another look at bash.  I thought I'd share my perception of the
differences between tcsh and bash.

The big thing tcsh is lacking, and the reason I switched, is the lack of
sensible redirection (as some call it).  Specifically, not being able to
do 'command 2/dev/null /somefile' is why I switched. 

The which command functions differently between bash and tcsh.  For
example, I have ls aliased to do color output and add some other options
that I like.  With tcsh, 'which ls' returns 
ls: aliased to \ls -GFB; with bash it returns 
/bin/ls.  The tcsh behavior tells you what will be executed when you
run ls.  The bash behavior can be achieved in tcsh with 'which \ls', so
I think I like the tcsh behavior better.  I could probably write a
function in bash that emulates tcsh's builtin which command.

The alias mechanism in bash lacks the ability to do parameter
substitutions like tcsh can.  You can achieve the same thing with bash
functions.  The disadvantage of this is it doesn't show up in the
aliases list.  I worked around this by adding aliases for the functions
too (because of the which behavior).  The advantage of using bash's
functions is you can do more complex things.

With bash-completions installed, the two shells both do completions
well.  Bash lacks the enhance mode of tcsh that considers periods,
hyphens and underscores (‘.’, ‘-’ and ‘_’)  to  be word  separators  and
hyphens and underscores to be equivalent.  Both can do case insensitive
completions.

Bash completions do remote file completion, a feature I longed for in
tcsh.  There are some bugs in the bash-completions code, mostly due to
its age.  For example, the _rsync function still has the default shell
as rsh and remote file completion does not work.

I think tcsh completions are a little easier to set up, but you can do
more with bash completions.

Those are the big differences that I've noticed so far.  All in all, the
transition has been fairly easy.

I hope someone will find my observations useful.

Dan


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Switched to Bash and Comparison of Shells

2010-06-10 Thread Lowell Gilbert
Dan D Niles d...@more.net writes:

 The which command functions differently between bash and tcsh.  For
 example, I have ls aliased to do color output and add some other options
 that I like.  With tcsh, 'which ls' returns 
 ls:   aliased to \ls -GFB; with bash it returns 
 /bin/ls.  The tcsh behavior tells you what will be executed when you
 run ls.  The bash behavior can be achieved in tcsh with 'which \ls', so
 I think I like the tcsh behavior better.  I could probably write a
 function in bash that emulates tcsh's builtin which command.

bash (like most other sh-style shells) has no which builtin.  You end
up running /usr/bin/which.  bash (like most other sh-style shells) does
have a (rough) equivalent, which is type.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Switched to Bash and Comparison of Shells

2010-06-10 Thread Dan Nelson
In the last episode (Jun 10), Lowell Gilbert said:
 Dan D Niles d...@more.net writes:
 
  The which command functions differently between bash and tcsh.  For
  example, I have ls aliased to do color output and add some other options
  that I like.  With tcsh, 'which ls' returns 
  ls: aliased to \ls -GFB; with bash it returns 
  /bin/ls.  The tcsh behavior tells you what will be executed when you
  run ls.  The bash behavior can be achieved in tcsh with 'which \ls', so
  I think I like the tcsh behavior better.  I could probably write a
  function in bash that emulates tcsh's builtin which command.
 
 bash (like most other sh-style shells) has no which builtin.  You end up
 running /usr/bin/which.  bash (like most other sh-style shells) does have
 a (rough) equivalent, which is type.

zsh's which command will prints the output of aliases, and a very
comprehensive completion system, too.  It also supports more csh
features/syntax than bash (good for people used to csh/tcsh).

(d...@dan.13) /home/dan which ls
ls: aliased to ls -Fa

-- 
Dan Nelson
dnel...@allantgroup.com
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Switched to Bash and Comparison of Shells

2010-06-10 Thread Jerry
On Thu, 10 Jun 2010 13:41:32 -0400
Lowell Gilbert freebsd-questions-lo...@be-well.ilk.org articulated:

 bash (like most other sh-style shells) has no which builtin.  You
 end up running /usr/bin/which.  bash (like most other sh-style
 shells) does have a (rough) equivalent, which is type

Personally, I have found the command equivalent quite adequate. I use
a version of the following in all of my Bash scripts that require
checking for the presents of another program.

command -v command1 /dev/null  echo command1 Found In \$PATH || echo 
command1 Not Found in \$PATH

-- 
Jerry
freebsd.u...@seibercom.net

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.
__

Sure you can trust the Government; ask any Indian.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Switched to Bash and Comparison of Shells

2010-06-10 Thread Malcolm Kay
On Fri, 11 Jun 2010 02:49 am, Dan D Niles wrote:
 I had been using csh/tcsh for 20 years and I just switched to
 bash.  The recent discussion about the differences between the
 shells prompted me to take another look at bash.  I thought
 I'd share my perception of the differences between tcsh and
 bash.

It seems to me that it is a little late in the day to be changing
to bash. Some well known Linux distributions are beginning to see 
that some non-posix features of bash can create difficulties. I 
believe recent releases of Ubuntu use dash as the prefered 
shell, and it looks as though Debian will be going the same way.
Dash is supposed to be a modern, faster and cleaner 
implementation of sh -- if installed through FBSD ports it has 
the same man page as sh.


 The big thing tcsh is lacking, and the reason I switched, is
 the lack of sensible redirection (as some call it). 
 Specifically, not being able to do 'command 2/dev/null
 /somefile' is why I switched.

I'm also a long time csh/tcsh user (somewhat more than 20 years)
and freely admit that redirection at the command line can 
occassionally be a problem. I've always used sh for any serious
scripting.

Unless you wish to play with one or other fairly common but 
lesser known shells such as zsh or ksh then I would suggest that
sh or dash (perhaps with a -E or -V option for interactive use) 
would be more appropriate than bash in a modern OS.

But ultimately each to his own.

Good luck,

Malcolm
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash instead of csh (completely)

2010-06-05 Thread ill...@gmail.com
On 4 June 2010 14:56, Stefan Miklosovic miklosovic.free...@gmail.com wrote:
 Hi list,

 title says it, i would like completely remove csh and install bash
 instead. As far I know, csh is build in system, could I remove it
 manually and install bash (of course, in reverse order :D)

 Are there such dependencies on csh? I know that real system scripting
 is done via /bin/sh
 co absence of csh shell should not break system.

 Am I wrong ?

Entirely removing [t]csh sounds like a frustrating
exercise in futility, but have fun.

But before you switch your root shell to something
that resides not in your root partition:
http://forums.freebsd.org/showthread.php?t=14676

-- 
--
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


bash instead of csh (completely)

2010-06-04 Thread Stefan Miklosovic
Hi list,

title says it, i would like completely remove csh and install bash
instead. As far I know, csh is build in system, could I remove it
manually and install bash (of course, in reverse order :D)

Are there such dependencies on csh? I know that real system scripting
is done via /bin/sh
co absence of csh shell should not break system.

Am I wrong ?

Thank you for reply

Have a nice day
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash instead of csh (completely)

2010-06-04 Thread Chris Rees
Why would you want to do that?

On 4 Jun 2010 19:57, Stefan Miklosovic miklosovic.free...@gmail.com
wrote:

Hi list,

title says it, i would like completely remove csh and install bash
instead. As far I know, csh is build in system, could I remove it
manually and install bash (of course, in reverse order :D)

Are there such dependencies on csh? I know that real system scripting
is done via /bin/sh
co absence of csh shell should not break system.

Am I wrong ?

Thank you for reply

Have a nice day
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash instead of csh (completely)

2010-06-04 Thread Jerry McAllister
On Fri, Jun 04, 2010 at 08:56:02PM +0200, Stefan Miklosovic wrote:

 Hi list,
 
 title says it, i would like completely remove csh and install bash
 instead. As far I know, csh is build in system, could I remove it
 manually and install bash (of course, in reverse order :D)

If you are made about that, then just change your shell in 
the /etc/passwd file to  /usr/local/bin/bash   and you
will have bash as your shell.   

There is no particular reason to do so, but you can if you want.

Actually, the csh on FreeBSD is now tcsh and has most of the
cute features added that some people think they have to use bash
for.  Of course, the syntax for commands is still csh style.

 
 Are there such dependencies on csh? I know that real system scripting
 is done via /bin/sh
 co absence of csh shell should not break system.

You do not want to make bash be the default shell for root.
It should be left  as /bin/sh 

jerry


 
 Am I wrong ?
 
 Thank you for reply
 
 Have a nice day
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash instead of csh (completely)

2010-06-04 Thread Polytropon
On Fri, 4 Jun 2010 20:56:02 +0200, Stefan Miklosovic 
miklosovic.free...@gmail.com wrote:
 Hi list,
 
 title says it, i would like completely remove csh and install bash
 instead. As far I know, csh is build in system, could I remove it
 manually and install bash (of course, in reverse order :D)
 
 Are there such dependencies on csh? I know that real system scripting
 is done via /bin/sh
 co absence of csh shell should not break system.
 
 Am I wrong ?

Hmmm... first of all, you know that there are some things you have
to take into mind when installing bash into the OS (e. g. attention
to use statical linking, and placing it into /bin). Keep in mind
that FreeBSD defaults to csh as the default dialog shell in many
places (e. g. /usr/share/skel), but you can also modify those
references to point to bash instead.

I don't know why you want to remove csh from the system (instead
of just not using it), but in my opinion - without any experience
or testing - it sounds possible.

You can easily build a minimal system, install bash as mentioned
before, and then remove the csh binary.



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash instead of csh (completely)

2010-06-04 Thread Uwe Laverenz

Am 04.06.2010 20:56, schrieb Stefan Miklosovic:


title says it, i would like completely remove csh and install bash
instead. As far I know, csh is build in system, could I remove it
manually and install bash (of course, in reverse order :D)


What do you want to achieve with this? Installing shells/bash from ports 
followed by a chsh or vipw is not sufficient?


If you really want a system without csh please have a look at 
src.conf(5) which has the knob you want:


WITHOUT_TCSH
  Set to not build and install /bin/csh (which is tcsh(1)).

If you add WITHOUT_TCSH=YES to your /etc/src.conf you probably can get 
rid of csh after the next buildworld with the commands make delete-old; 
make delete-old-libs


Uwe
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash instead of csh (completely)

2010-06-04 Thread Michael Powell
Stefan Miklosovic wrote:

 Hi list,
 
 title says it, i would like completely remove csh and install bash
 instead. As far I know, csh is build in system, could I remove it
 manually and install bash (of course, in reverse order :D)
 
 Are there such dependencies on csh? I know that real system scripting
 is done via /bin/sh
 co absence of csh shell should not break system.

Why do you feel it is necessary to completely remove csh? It is part of the 
base install of the OS and does not prevent you from installing and using 
Bash should you choose. Since these are not mutually exclusive I see no 
reason to remove csh. Just leave it be. Arbitrarily 'removing' stuff from 
the base system without relevant reason is more likely to create a problem 
where none existed previously.

You can install Bash from ports. You should know that it is a third party 
userland application at this point. What you will find out some day when 
/usr won't mount and you're sitting in single-user mode trying to recover 
the box is bash will not be working. And if you made the mistake of changing 
root's shell to bash you will not be a happy camper.

You are certainly free to use whatever shell you want as a user. Don't mess 
with root's shell. I saw once some highly questionable so-called 
'benchmarking' where it was claimed that bash is 4 times slower than 
anything else. My own $.02 is the fixation on bash is more a result from 
people coming over to FreeBSD from Linux, and trying to drag Linux 
methodologies along with instead of looking at FreeBSD fresh and learning 
new stuff. While there is a lot of similarity and overlap, FreeBSD is *not* 
just another Linux distro.

-Mike
 




___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash instead of csh (completely)

2010-06-04 Thread Jerry B. Altzman
On Fri, Jun 4, 2010 at 14:59, Chris Rees utis...@gmail.com wrote:

 Why would you want to do that?


To get rid of csh?
http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

//jbaltz
-- 
jerry b. altzmanjba...@gmail.com  www.jbaltz.com
foo mane padme hum  twitter: @lorvax
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash instead of csh (completely)

2010-06-04 Thread Eric Masson
Jerry B. Altzman jba...@gmail.com writes:

Hi,

 To get rid of csh?
 http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

This link is about csh *programming*, as standard scripts in FreeBSD use
sh, this is pointless.

Regards

-- 
 Ol: ..un plan perdu au fond d'une armoire dont seul Steve Jobs a la clé.
 BL: Qu'il a laissée dans un pantalon déposé chez un teinturier dont il a
 perdu l'adresse et le ticket !
 -+- BL in Guide du Macounet Pervers : Bien cacher sa stratégie -+-
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash instead of csh (completely)

2010-06-04 Thread Polytropon
On Fri, 4 Jun 2010 16:03:42 -0400, Jerry B. Altzman jba...@gmail.com wrote:
 On Fri, Jun 4, 2010 at 14:59, Chris Rees utis...@gmail.com wrote:
 
  Why would you want to do that?
 
 
 To get rid of csh?
 http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

The article you mentioned discusses the topic Why shouldn't I 
program in csh? As the OP already noted correctly, in FreeBSD
scripting is done by /bin/sh, the Bourne shell. Most people
scripting on FreeBSD do also use sh. In fact, I don't know
anybody seriously scripting in csh.

In terms of dialog shell quality, there surely are better
solutions than bash. Allthough bash is most common, shells
like ksh or zsh are also very powerfull (and still have
compatibility to sh). Personally, there are some things
regarding dialog use that csh does better (!) than bash,
but that's to be seen as what it is, a very individual point
of view.

Again, why get rid of csh when it's enough just not to use
it? System scripting is sh, and using chsh, modification of
adduer behaviour or different settings in /usr/share/skel
bash can be made the default dialog shell - no big deal.



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash instead of csh (completely)

2010-06-04 Thread Stefan Miklosovic
Hi all,

First of all, thank you for your quick answers, I really appreciate it.

I dont want to start flame war about linux vs bsd but ... :)
Before I start to explain what I want to do, I want you know
I consider freebsd fr away better than linux in a lot of ways.
(it is also a reason I want to build something upon bsd instead of
linux, there are so many advantages ... ok, this post isnt about that :))

In work, we try to do some kind of linux distro, it is based on slacware.
I am not a guy who lead it, but in the way we are developing it, I think it is
 bad idea at all. Firstly, we try to do minimal slackware installation
as much it is possible, so now we are about 2.6.34 kernel, minimum
kernel modules, no man or docs, files you do not need for sure are removed.
We ended with quite usable system with quite neccessary utilities. It has
about ~150 MB.

But I think with this process, we just cut ourselves from such things like
system upgrade (if slackware would have someone :D), package upgrade
(we nearly all do manually, compiling from source) and so on ...
Note that this distro is not something massively distributed, just for
our purpose,
but problems remains.

While I always inclined to *bsd and not used linux more as it was a duty, I
want to do it in bsd way. So set up minimal bsd without things I do not need
but still stay in touch with things like package system, ports (its the same)
and system upgrades / updates. I should write my own installer and so on.

What I still miss is a way how to bend freebsd to my needs. In
linux, it is easy
as hell, remove this, change that, and it still runs. I am afraid that
if I cut off some
parts of system, I will not benefit from it anymore. For example, I
install minimal bsd,
but it contains still things I do not need (some dir like games and other
stuff or some ancient groups in /etc/groups like uucp, proxy,games, dialer (???
in year 2010, who use it?) and so on.

So I am afraid to be so brutal to just remove it ...

FreeBSD has another philosophy than Linux, but i feel Linux is more
customizable.
But understand that it is advantage and disadvantage too ...

I think I have to more study about /usr/src/ :) For example, I would
like to know,
how to install something into other dir and no to default one. Think about port.
All to /usr/local/ ... and so on. But what if I want to install it in
/ExtraStuff ? How do
I do it in make install clean way? Change port's make file ? no way .

On 6/4/10, Michael Powell nightre...@hotmail.com wrote:
 Stefan Miklosovic wrote:

 Hi list,

 title says it, i would like completely remove csh and install bash
 instead. As far I know, csh is build in system, could I remove it
 manually and install bash (of course, in reverse order :D)

 Are there such dependencies on csh? I know that real system scripting
 is done via /bin/sh
 co absence of csh shell should not break system.

 Why do you feel it is necessary to completely remove csh? It is part of the
 base install of the OS and does not prevent you from installing and using
 Bash should you choose. Since these are not mutually exclusive I see no
 reason to remove csh. Just leave it be. Arbitrarily 'removing' stuff from
 the base system without relevant reason is more likely to create a problem
 where none existed previously.

 You can install Bash from ports. You should know that it is a third party
 userland application at this point. What you will find out some day when
 /usr won't mount and you're sitting in single-user mode trying to recover
 the box is bash will not be working. And if you made the mistake of changing
 root's shell to bash you will not be a happy camper.

 You are certainly free to use whatever shell you want as a user. Don't mess
 with root's shell. I saw once some highly questionable so-called
 'benchmarking' where it was claimed that bash is 4 times slower than
 anything else. My own $.02 is the fixation on bash is more a result from
 people coming over to FreeBSD from Linux, and trying to drag Linux
 methodologies along with instead of looking at FreeBSD fresh and learning
 new stuff. While there is a lot of similarity and overlap, FreeBSD is *not*
 just another Linux distro.

 -Mike





 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash instead of csh (completely)

2010-06-04 Thread C. P. Ghost
On Fri, Jun 4, 2010 at 10:54 PM, Stefan Miklosovic
miklosovic.free...@gmail.com wrote:
 What I still miss is a way how to bend freebsd to my needs. In
 linux, it is easy
 as hell, remove this, change that, and it still runs. I am afraid that
 if I cut off some
 parts of system, I will not benefit from it anymore. For example, I
 install minimal bsd,
 but it contains still things I do not need (some dir like games and other
 stuff or some ancient groups in /etc/groups like uucp, proxy,games, dialer 
 (???
 in year 2010, who use it?) and so on.

You're aware of nanobsd(8)?

-cpghost.

-- 
Cordula's Web. http://www.cordula.ws/
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash instead of csh (completely)

2010-06-04 Thread b. f.
I dont want to start flame war about linux vs bsd but ... :)
Before I start to explain what I want to do, I want you know
I consider freebsd fr away better than linux in a lot of ways.
(it is also a reason I want to build something upon bsd instead of
linux, there are so many advantages ... ok, this post isnt about that :))

You're right -- it isn't about that.  Don't get sucked into some
stupid argument.  Bash isn't Linux.  Linux isn't bash.  If you want to
use another shell, just use it.  Bear in mind that if you install it
from FreeBSD Ports, then it and it's dependencies may not be available
in the event of an emergency, if they live on a partition separate
from /.  So unless you go to the trouble of building a
statically-linked bash and installing it in /rescue or /bin or
whatever, I wouldn't change root's shell to bash.  However, others
encountered this problem, and made a default account called toor
that is basically a root account with another shell.  You could use
that with bash instead, and leave root with a shell from the base
system. Whatever you decide to use for user accounts and your own
scripts, variables like MAKE_SH and SH in make.conf will dictate what
is used for building the base system and ports.  If you change these
to bash, you may break some builds.

...


What I still miss is a way how to bend freebsd to my needs. In
linux, it is easy
as hell, remove this, change that, and it still runs. I am afraid that
if I cut off some
parts of system, I will not benefit from it anymore. For example, I
install minimal bsd,
but it contains still things I do not need (some dir like games and other
stuff or some ancient groups in /etc/groups like uucp, proxy,games, dialer (???
in year 2010, who use it?) and so on.

So I am afraid to be so brutal to just remove it ...

It's just a matter of learning what depends on what, which takes a bit
of time.  If you're happy with a ~150MB base system, you can just use
the WITHOUT_* knobs in src.conf(5)  and the make delete-old(-libs)
targets to rip out a bunch of stuff.  If you want it even smaller,
you'll have to use picobsd(8), or nanobsd(8) (both of which require
some effort to figure out dependencies), or hack the base system
sources yourself.


FreeBSD has another philosophy than Linux, but i feel Linux is more
customizable.

Maybe some Linux distros are slightly easier to trim than the stock
FreeBSD, but only slightly.  Once you become more familiar with
FreeBSD, I'm sure that you will see the possibilities for slimming it
down.  If you are still not satisfied, you could use a hybrid system
like Debian's GNU/kfreebsd:

http://www.debian.org/ports/kfreebsd-gnu/

or Gentoo/FreeBSD:

http://www.gentoo.org/proj/en/gentoo-alt/bsd/fbsd/

But these are newer, experimental systems, with all that implies.


I think I have to more study about /usr/src/ :) For example, I would
like to know,
how to install something into other dir and no to default one. Think about 
port.
All to /usr/local/ ... and so on. But what if I want to install it in
/ExtraStuff ? How do
I do it in make install clean way? Change port's make file ? no way .

Read build(7), release(7), ports(7), src.conf(5), make.conf(5),
/usr/ports/Mk/bsd.port.mk, /usr/src/Makefile, and the tail of
/usr/src/UPDATING, for a start.  You'll want to look at setting
DESTDIR, LOCALBASE, etc.  It's all there.  Good luck.


b.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: bash instead of csh (completely)

2010-06-04 Thread Chad Perrin
On Fri, Jun 04, 2010 at 04:03:42PM -0400, Jerry B. Altzman wrote:
 On Fri, Jun 4, 2010 at 14:59, Chris Rees utis...@gmail.com wrote:
 
  Why would you want to do that?
 
 To get rid of csh?
 http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

As pointed out already (at least twice), that is about csh *programming*.
What this means is that nothing in that screed says that having csh
installed on your system is bad.  If you actually buy everything that
Mr. Christiansen says about how csh is bad for programming (and I don't
buy everything he says there, though I do agree with him on a lot of
other topics, particularly where Perl is concerned), you still have no
reason based on that screed to avoid using csh (or tcsh) as your
interactive shell.

Furthermore, there are reasons you shouldn't use bash for scripting.  It
is rather dependency-heavy, for a shell, and if you're going to write
shell scripts you should really try to write them to be as simple, and as
widely understandable and portable, as possible.  This basically means sh
(the Bourne shell) rather than csh, tcsh, bash, zsh, ksh, et cetera.
Even the sh-emulation that bash provides, and that many Linux systems use
instead of a real sh, is less than perfect in that regard -- but it's
close enough for government work, I suppose.

I'm about to get very opinionated, so feel free to stick your fingers in
your ears if you don't like what I have to say:

If you get to the point where your programming efforts are so
sophisticated that you can't make do with sh, you should be using a
real programming language, rather than a shell that happens to allow
scripting.  This means that by the time sh (with grep, awk, et cetera)
isn't good enough, you should really consider using something like Perl
or Ruby.  By the time sh isn't really sufficient, you're talking about
real programming, by which point the lack of clarity of the syntax of
the typical shell languages can become a real thorn in your side when it
comes to maintenance.

Maybe it's just me, but just as I don't see any particular need for MS
Access as a DBMS when it's overlapped by spreadsheets and SQLite on one
end and by a variety of more serious DBMSes like PostgreSQL on the
other end, I don't really see much point for bash as a scripting language
when it's significantly overlapped by sh on one end and Perl, Ruby, et
cetera on the other end.  I suppose your mileage may vary.

Anyway . . . ultimately, my point is that I love tcsh as an interactive
shell, and never use it for programming.  I find it odd that people
want to do programming in a typical Unix shell other than simple
scripting in sh when there are such better options available.

Perl is even more ubiquitous than bash.  Why not just use that for
scripting if you want more than sh?

-- 
Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]


pgpwjTRSVHMj7.pgp
Description: PGP signature


  1   2   3   4   5   6   7   >