Sponsored Content
Top Forums UNIX for Dummies Questions & Answers read fails in Unix, but succeeds in Linux. Why? Post 302623035 by HgHK on Friday 13th of April 2012 04:23:41 AM
Old 04-13-2012
read fails in Unix, but succeeds in Linux. Why?

Hi,

When I use "read" to parse the sftp command sent via ptty, I ran into a very mysterious case below:
---
In Unix, the command ‘quit' is lost.
===
Fri 13Apr12 15:42:47GMT-sftp_send_command: SENT [quit^M]
Fri 13Apr12 15:42:47GMT-sftp_read_resp_line: Parse buffer=quit^M --> Command sent correctly
Fri 13Apr12 15:42:47GMT-sftp_read_resp_line: Parse buffer char ptr=^M --> only parse the last character.
===
In Linux, everything working fine.
--
Fri 13Apr12 07:59:29GMT-sftp_send_command: SENT [quit^M]
Fri 13Apr12 07:59:29GMT-sftp_read_resp_line: Parse buffer=quit^M
Fri 13Apr12 07:59:29GMT-sftp_read_resp_line: Parse buffer char ptr=q
Fri 13Apr12 07:59:29GMT-sftp_read_resp_line: Parse buffer char ptr=u
Fri 13Apr12 07:59:29GMT-sftp_read_resp_line: Parse buffer char ptr=i
Fri 13Apr12 07:59:29GMT-sftp_read_resp_line: Parse buffer char ptr=t
Fri 13Apr12 07:59:29GMT-sftp_read_resp_line: Parse buffer char ptr=^M
--
The following codes are used to parse the sftp command, what's going wrong in UNIX system? How to correct it?
---
ret = select (sftp->msfds[MASTER_FD]+1, &fd, NULL, NULL, &tv);
...
/* read byte by byte to catch the '\n' */
nread = read (sftp->msfds[MASTER_FD], (void *) ptr, 1); -> same in Unix and Linux systems.
...
Really appreciate any help.

Best regards,
HK
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

im very new to unix/linux can someone tell me the best books to read...

im very new to unix/linux operating system and having a hard time understanding the command ( grep, ls, echo and variables) is there any book that is simple to understand... after taking this unix/linux operating system i need to take unix operating system..can someone help me please!!! (1 Reply)
Discussion started by: 2071fox
1 Replies

2. Programming

while vc++6 succeeds, g++ fails. ???

My code is at: http://rafb.net/p/E82U3C73.html It is a concept sample. I desperately tried to compile it with g++. To my surprise (in vmplayer/ win2k) vc++6 succeeds to compile it. I'm in very doubt. I used RedHat WS 4 , g++-3.4 and Debian Etch, g++-4.1 Comment this please!! mihai (4 Replies)
Discussion started by: mihk
4 Replies

3. What is on Your Mind?

Time to have FUN my Unix/Linux friends...(One liners)...MUST read.. !!

As a mind refresher, I was thinking to start a new thread for ONE LINERS....funny/weird or any technical one liners.... Let me start first...... ================================= #!/bin/ssh #The Unix Guru's View of Sex unzip ; strip ; touch ; grep ; finger ; mount ; fsck ; more ; yes ;... (3 Replies)
Discussion started by: Rahulpict
3 Replies

4. Shell Programming and Scripting

execute ftp script until it succeeds

I have a ftp script that occasionally fails (connection lost error). I would like to execute the ftp command until it succeeds. Would the script below work? while do ftp -i -n <<EOF >> $LOG open $FTP_HOST user $FTP_LOGIN $FTP_PASSWD put filename.csv bye quit ... (5 Replies)
Discussion started by: soliberus
5 Replies

5. Shell Programming and Scripting

Expect: Block of lines should be executed only if access succeeds

Hello I'm using expect to create a script. I want some lines to be executed only if the telnet succeeds to the target host. Kindly check the code that i created. The problem i'm facing that while execting the script, the lines after login seems to be ignored. The password is not sent and also... (2 Replies)
Discussion started by: Hossam_Nox
2 Replies

6. Programming

Linux: dlopen fails to find symbols

I've attached a tar.gz containing three tests to demonstrate the problem I'm having. Within the tar are two shared libraries, two test applications, and a Makefile that builds the three tests. The shared libaries are libshlib1.so and libshlib2.so. Both export a function, libFunc, which takes... (5 Replies)
Discussion started by: DreamWarrior
5 Replies

7. UNIX and Linux Applications

Tomcat 6.0 fails to read symlink(symbolic link) file

Hello all experts, Im in a situation where Tomcat simply does not want to read this file through the symlink.... I checked permissions..OK Also checked file & tomcat owner...all OK. This is what I have my /tomcat/conf/Catalina/local/appname.xml <Context> <Resource name="jdbc/black" ... (3 Replies)
Discussion started by: KingaKoopa
3 Replies

8. UNIX for Advanced & Expert Users

Sendmail succeeds, qmail fails

I am attempting to send multipart formatted email using sendmail -t with attachments. The attachments always arrive as empty if sent from linux. They are intact if sent from AIX. Does qmail not support attachments for multipart formatted email? I have a legacy application which runs... (4 Replies)
Discussion started by: charles_n_may
4 Replies

9. UNIX for Advanced & Expert Users

Z/os USS: 'man' fails to read bookmaster

we have two z/OS instances, on one the 'man' command finds input content, formats and displays it and caches the results. All good: SYS$JB:/VERSYSB/usr/man/C/man1: >man -x date Trying /usr/man/C/cat1/date.1 Trying /var/man/C/date.1.* Trying /usr/man/C/man1/*.book Trying... (0 Replies)
Discussion started by: maraixadm
0 Replies

10. Shell Programming and Scripting

sed works on Linux but fails on Solaris

Hi, On Linux i get the desired ouput: echo "<value>WEB_USER</value>" | sed 's/\(<value>\|<\/value>\)//g'Output: Executing the same command on Solaris: echo "<value>WEB_USER</value>" | sed 's/\(<value>\|<\/value>\)//g'Output: I need to get the desired output on Solaris i.e. WEB_USER and... (4 Replies)
Discussion started by: mohtashims
4 Replies
sftp-server(1M)                                           System Administration Commands                                           sftp-server(1M)

NAME
sftp-server - SFTP server subsystem SYNOPSIS
/usr/lib/ssh/sftp-server DESCRIPTION
sftp-server implements the server side of the SSH File Transfer Protocol as defined in the IETF draft-ietf-secsh-filexfer. sftp-server is a subsystem for sshd(1M) and must not be run directly. There are no options or config settings. To enable the sftp-server subsystem for sshd add the following to /etc/ssh/sshd_config: Subsystem sftp /usr/lib/ssh/sftp-server See sshd_config(4) for a description of the format and contents of that file. There is no relationship between the protocol used by sftp-server and the FTP protocol (RFC 959) provided by in.ftpd. EXIT STATUS
The following exit values are returned: 0 Successful completion. >0 An error occurred. FILES
/usr/lib/sftp-server ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWsshdu | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
sftp(1), ssh(1), ssh-add(1), ssh-keygen(1), sshd(1M), sshd_config(4), attributes(5) To view license terms, attribution, and copyright for OpenSSH, the default path is /var/sadm/pkg/SUNWsshdr/install/copyright. If the Solaris operating environment has been installed anywhere other than the default, modify the given path to access the file at the installed location. AUTHOR
Markus Friedl SunOS 5.10 30 Jul 2003 sftp-server(1M)
All times are GMT -4. The time now is 07:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy