[TriLUG] SCP acting funny
Aaron S. Joyner
aaron at joyner.ws
Mon Apr 5 14:06:39 EDT 2004
You can check to see if a shell is interactive or not by testing whether
or not PS1 is set, or seeing whether $- contains `i`.
From the bash man page:
> An interactive shell is one started without non-option
> arguments and
> without the -c option whose standard input and output are
> both con-
> nected to terminals (as determined by isatty(3)), or one
> started with
> the -i option. PS1 is set and $- includes i if bash is
> allowing a shell script or a startup file to test this state.
According to the first response when googling "scp bashrc" this behavior
changed with bash 2.02 when they added code to attempt to detect if ssh
shells were interactive or not, and set the "interactivity"
accordingly. Thus, testing $PS1 or $- may or may not work properly.
Unfortunately, I don't have time to test it thoroughly at the moment.
Let us know how it turns out.
Brian A. Henning wrote:
>Ah, yes, that definitely seems to be it exactly.. Any output from a bashrc
>appears to confuse scp.. Apparently it closes the connection after it sees
>a line-feed character in the stdout stream. Not being a wisened programmer,
>I can only speculate as to why it was coded that way.
>At any rate, I do not wish to forfeit the output of my ~/.bashrc if I can
>avoid it. Is there any sort of condition I could check to conditionally
>branch around the output only when scp is making the connection? Like some
>environment variable or perhaps the parent process that spawns the instance
>of bash? Something akin to this pseudo-shellcode:
>if [remote_command ne "scp"]; then
>Thanks everyone that offered suggestions.
>>From: trilug-bounces at trilug.org [mailto:trilug-bounces at trilug.org]On
>>Behalf Of bp
>>Sent: Monday, April 05, 2004 8:51 AM
>>To: Triangle Linux Users Group discussion list
>>Subject: Re: [TriLUG] SCP acting funny
>>On Sun, 4 Apr 2004, James Manning wrote:
>>>>Could it be the output from /etc/bashrc is somehow confusing the
>>>Maybe - as a quick sanity check I'd rename the relevant .bashrc /
>>>.profile files (any of them that get run at ssh/scp time, checking
>>>access times should help if you're unsure) so they're not run at all
>>On RedHat 9 I too noticed this horrible behaviour; any output coming from
>>bashrc (welcome to host xyz) caused scp to connect and immediately
>>disconnect with no file being transfered. Get rid of the output and the
>>issue will be fixed. This was the case on several of my lab boxes
>>TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
>>TriLUG Organizational FAQ : http://trilug.org/faq/
>>TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
>>TriLUG PGP Keyring : http://trilug.org/~chrish/trilug.asc
More information about the TriLUG