LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-11-2008, 11:56 PM   #1
funkymunky
Member
 
Registered: Jun 2003
Location: Austin, Texas
Distribution: Fedora Core 8, 32-bit
Posts: 126

Rep: Reputation: 15
Red face Problem with scp (ssh) on adding /usr/bin/fortune to /etc/profile & .bashrc (Fedora)


Hi everyone,

I kinda like the fortune messages, so I added /usr/bin/fortune to both my ~/.bashrc and /etc/profile (the latter because i wanted this to be system wide, so was looking for alternative to adding this line to the bashrc of every user..not sure if this is the correct way).

Anyway, now I'm unable to scp (ssh-copy) a file from this machine, by logging in from another machine. When I try this from machine B:

B~>scp A:<file> ./
password:

When I enter the password, I get the /usr/bin/fortune message, instead of the file transfer starting
What am I doing wrong?

TIA,
Mayank
 
Old 09-12-2008, 12:43 AM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
Place this if around your call to fortune:

Code:
if [ ! -z "$PS1" ] ; then
  fortune
fi
This will prevent fortune from trying to run on non-interactive shells.
 
Old 09-12-2008, 03:16 AM   #3
funkymunky
Member
 
Registered: Jun 2003
Location: Austin, Texas
Distribution: Fedora Core 8, 32-bit
Posts: 126

Original Poster
Rep: Reputation: 15
Thanks, Mr. C. Didn't work tho
Code:
[root@localhost ~]# scp mkaushik@blah:~/work/bugs/xyz .
mkaushik@blah's password:
I could dance with you till the cows come home.  On second thought, I'd rather
tail ~/.bashrc:

Code:
if [ ! -z "PS1" ]; then
    /usr/bin/fortune
    echo -e "\n"
fi
 
Old 09-12-2008, 03:43 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Any output coming from a command in .bashrc can trigger the scp errors. Moreover if you execute remote commands using ssh, the output will come out together with the requested one. For example when you do something like
Code:
ssh user@host ls
the fortune message will be "listed" together with the list of files. To prevent this behaviour, put the fortune command in .bash_profile. You will get the output when you login through ssh, but not when using scp or when issuing remote commands.
 
Old 09-12-2008, 04:57 AM   #5
funkymunky
Member
 
Registered: Jun 2003
Location: Austin, Texas
Distribution: Fedora Core 8, 32-bit
Posts: 126

Original Poster
Rep: Reputation: 15
Now fortune doesn't work :sad:

Why does my .bash_profile not get executed when i login?

Code:
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

echo -e "Test\n"
PATH=$PATH:$HOME/bin

export PATH

/usr/bin/fortune
echo -e "\n"
 
Old 09-12-2008, 05:04 AM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Which is the exact command you use to connect? See the INVOCATION section in man bash for more information.

An aside note: to print out a newline you can simply issue an echo alone:
Code:
/usr/bin/fortune && echo
 
Old 09-12-2014, 03:06 AM   #7
gamboz
LQ Newbie
 
Registered: Sep 2014
Posts: 2

Rep: Reputation: Disabled
from
http://winscp.net/forum/viewtopic.php?t=1510

Code:
if [ "$TERM" != "dumb" ]; then
    fortune
fi
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting path: /etc/profile, /etc/bashrc or ~/.bashrc Swakoo Linux - General 1 08-07-2007 10:59 PM
Ubuntu 5.10 -> 6.06: diversion of /usr/bin/ldd to /usr/bin/ldd.amd64 by ia32-libs HellSpawn Linux - Software 2 06-04-2006 09:18 PM
path in services wrong for clamav updated frm 0.75 to 0.80 usr/bin vs usr/local/bin Emmanuel_uk Linux - Newbie 3 04-22-2005 01:02 AM
Shell Script with ssh & scp ErikJohnson Linux - Software 3 03-11-2004 04:53 PM
ssh issue: /usr/bin/ssh -x -oFallBackToRsh no -l WeNdeL Linux - Software 1 03-04-2003 07:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration