Re: /etc/bashrc help!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Tuesday 19 April 2011 20:18:38 Roland Roland wrote:
>   Dear all,
> 
> i've appended the below to /etc/bashrc it works like a charm with ssh
> connections though SFTP sessions fail since the below is being sent to
> the intiator.
> any way of limiting the below to none sftp sessions? or any other idea
> for it to work?
> 
> 
> # If id command returns zero, you’ve root access.
> if [ $(id -u) -eq 0 ];
> then # you are root, set red colour prompt
> echo "###############################################"
> echo "### You are now working as ROOT. ###"
> echo "### Pay attention to what you type. ###"
> echo "###############################################"
> PS1="\\[$(tput setaf 1)\\]\\u@\\h:\\w #\\[$(tput sgr0)\\]"
> else # normal
> echo
> echo " ###########################################################"
> echo "Welcome $(whoami), here's something to start your day with:"
> echo
> echo `sh /etc/lines.sh /etc/quotes.txt`
> echo " ############################################################"
> echo
> PS1="[\\u@\\h:\\w] $"
> fi
> 

Rolan, you have two choices:

1. Print the whole content on STDERR so you don't disturb the sftp

2. if [ "$-" != 'hBc' ]; then echo 'your content here'; fi

If you go to the second option, the idea there is that $- is set to hBc every 
time you use the shell from SFTP (non-interactive mode). So you echo all the 
things you like only if it is an interactive shell.

Marian

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux