Sponsored Content
Top Forums Shell Programming and Scripting Banner causes scp to fail from script but not command line. Post 302543823 by RECrerar on Tuesday 2nd of August 2011 11:48:40 AM
Old 08-02-2011
Banner causes scp to fail from script but not command line.

Hi,

We have an interesting issue which is similar to the one in this thread, but that never provided a full answer. - Ohh apparently I can't post URLs till I have 5 posts, sorry.

We have a simple script that copies files from one shelf to the other. Both shelves have an ssh banner defined. When I run the script the scp to the remote shelf fails however if does not when the same command is run from the command line. When I pipe the output to a file, the error output displays the banner from the remote shelf.

Piping the error output to a file solves the problem and the scp works fine, however I don't understand why and I was wondering if anyone could explain. We have quite a few places in the code where the output is not currently piped to /dev/null (stderr) and I really want to understand the cause of the problem so that I know whether I need to correct all of them or just ones in certain formats/shells or indeed if it is a config problem?

The code I am running is as follows (I have removed any parts that could be company sensitive (e.g. <remote shelf ip> if not the actual code in this line but does work):

Code:
#!/usr/bin/ksh
VP3_REMOTE_SHELF_IP=`<remote shelf ip>`
/opt/OBSDssh/bin/ssh -n -o 'BatchMode yes' $VP3_REMOTE_SHELF_IP "rm -r -f /tmp/ms_passwd"
  /opt/OBSDssh/bin/ssh -n -o 'BatchMode yes' $VP3_REMOTE_SHELF_IP "mkdir /tmp/ms_passwd"
#SCP1 - this works
/opt/OBSDssh/bin/scp -o 'BatchMode yes' /etc/shadow $VP3_REMOTE_SHELF_IP:/tmp/ms_passwd/ > /dev/null 2>&1

#SCP2 - this does not work - the error output has to be piped away as well to make it work.
 /opt/OBSDssh/bin/scp -v -o 'BatchMode yes' /etc/passwd $VP3_REMOTE_SHELF_IP:/tmp/ms_passwd/ > /tmp/passwd

.....

When I run the scp with the -v option, this is the output I get (fjmfjf is the remote shelf banner - a pretty rubbish banner I'll admit, it has been like that for years though):

Code:
Executing: program /opt/OBSDssh/bin/ssh host <IP> user (unspecified), command scp -v -t /tmp/ms_passwd
OpenSSH_3.9p1, OpenSSL 0.9.7d 17 Mar 2004
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to <remote IP> [<remote IP>] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/1
debug1: identity file /etc/ssh_host_rsa_key type 1
debug1: Remote protocol version 2.0, remote software version OpenSSH_3.9p1
debug1: match: OpenSSH_3.9p1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_3.9p1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '<remote IP>' is known and matches the RSA host key.
debug1: Found key in /.ssh/known_hosts:5
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
fjmfjf
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering public key: /etc/ssh_host_rsa_key
debug1: Server accepts key: pkalg ssh-rsa blen 149
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending command: scp -v -t /tmp/ms_passwd
Sending file modes: C0644 569 passwd
Sink: C0644 569 passwd
ebug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.3 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0


If anyone could through some light on why this is happening it would be greatly appreciated. From my google investigations, I think it is something to do with the banner text being incorporated into the ssh command but that's about it.

Thanks

Moderator's Comments:
Mod Comment Un-bumped. See Rule 4

Last edited by pludi; 08-02-2011 at 03:40 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Banner command

Hey all, I want to use the banner/echo command to write messages on different console windows. I knew that before, but I completely forget how to do it ! I just remenber that /dev/pts/# is the number of the window. and it's useful. It would be great if someone knows how to solve my... (4 Replies)
Discussion started by: maxwell17
4 Replies

2. Linux

banner command

is there a similiar function to the solaris banner function in linux? (1 Reply)
Discussion started by: BG_JrAdmin
1 Replies

3. UNIX for Dummies Questions & Answers

banner command

can I use Banner command in Linux, if not, what is the similar command in linux then... (7 Replies)
Discussion started by: vasikaran
7 Replies

4. Shell Programming and Scripting

banner:command not found

hi, When i execute banner command the output is being displayed as banner:command not found When ever i give yum install banner the output is Loading "installonlyn" plugin Setting up Install Process Setting up repositories Parsing package install arguments Nothing to do what... (8 Replies)
Discussion started by: prakashreddy
8 Replies

5. Shell Programming and Scripting

doubt in banner command !!!

hello, I am using banner command in my shell.I used :- The problem is that the output is printed in 3 separate lines.I want to display it in a single line.If the size is not enough then at least 2 words should come in the same line. Can you tell me what is the option in banner that would help... (4 Replies)
Discussion started by: nsharath
4 Replies

6. Shell Programming and Scripting

regarding banner command

Iam a MCA student having some doubts about 1) different disk related commands 2) Banner command 3) Different file related commands 4) set eb (where it is used) (1 Reply)
Discussion started by: gururajbhat
1 Replies

7. UNIX for Dummies Questions & Answers

UNIX Banner Command

Hi, I am logging in into an UNIX environment with my user id and password. I want to display my name there , each time I login into the environment, for which I can use the banner command. Which file should I add the banner command to , so that I will get the desired result? Regards,... (7 Replies)
Discussion started by: Kishore_1
7 Replies

8. Shell Programming and Scripting

tr command fail to work in script

Hi, I has the following command in the script. This command works fine if I execute on command prompt. If I run the script, this is not working as expected (deleting CR). tr -d "\015" < ${FilePath}/${FileName} > ${FilePath}/${File_Prefix}.csv I could not figure out whats... (6 Replies)
Discussion started by: kavuri
6 Replies

9. Solaris

don't want banner displayed when using scp

:wall: Is there a way to prevent the banner from displaying from the remote host when using scp? I see from the man pages that the '-o' option passes args to ssh and I've tried several variations of: scp -o "-q" file remotehost: Anybody got this to work? Thanks in Advance (3 Replies)
Discussion started by: bluescreen
3 Replies

10. Shell Programming and Scripting

Banner command equivalent in Linux

Hi guys can i get banner equivalent command in linux. I am using Linux xcclx0619.target.com 2.6.18-308.11.1.el5xen #1 SMP Fri Jun 15 16:19:17 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux (1 Reply)
Discussion started by: mohanalakshmi
1 Replies
All times are GMT -4. The time now is 09:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy