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