read fails in Unix, but succeeds in Linux. Why?

Thread Tools Search this Thread
# 1  
read fails in Unix, but succeeds in Linux. Why?


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,
# 2  
Exactly which OSs are you talking about?
# 3  
The Unix is on 5.10 Generic_137111-06 sun4v sparc. and The Linux is on 2.6.18-238.1.1.el5 #1 SMP x86_64 x86_64 x86_64 GNU/Linux

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #341
Difficulty: Easy
Steve Jobs invented the first Apple Computer.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep works on Linux but fails on Solaris

Hi, On linux i have the below command working fine. grep -o '<name>.*</name>' deploy.tmp | sed 's/\(<name>\|<\/name>\)//g' deploy.tmp But the same is failing on Solaris uname -a SunOS mymac 5.10 Generic_150400-23 sun4v sparc sun4v Can you tell me how can i get it work on Solaris ?... (6 Replies)
Discussion started by: mohtashims
6 Replies

2. 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

3. 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

4. UNIX for Dummies Questions & Answers

Tcp connection to Linux server fails

I am trying to send json messages to a port on a linux server from a remote server running a .net program. I have one implementation running with successful incoming messages to port 1514. I tried to replicate the same thing but just to another port but cannot get it to work as I get the following... (3 Replies)
Discussion started by: unienewbie
3 Replies

5. 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

6. 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

7. 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

8. 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

9. Programming

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

My code is at: 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

10. 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

Featured Tech Videos