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
Postfix::Parse::Mailq(3pm)				User Contributed Perl Documentation				Postfix::Parse::Mailq(3pm)

NAME
Postfix::Parse::Mailq - parse the output of the postfix mailq command VERSION
version 1.001 SYNOPSIS
use Postfix::Parse::Mailq; my $mailq_output = `mailq`; my $entries = Postfix::Parse::Mailq->read_string($mailq_output); my $bytes = 0; for my $entry (@$entries) { next unless grep { /@aol.com$/ } @{ $entry->{remaining_rcpts} }; $bytes += $entry->{size}; } print "$bytes bytes remain to send to AOL destinations "; WARNING
This code is really rough and the interface will change. Entries will be objects. There will be some more methods. Still, the basics are likely to keep working, or keep pretty close to what you see here now. METHODS
read_file read_handle read_string my $entries = Postfix::Parse::Mailq->read_string($string, \%arg); This methods read the output of postfix's mailq from a file (by name), a filehandle, or a string, respectively. They return an arrayref of hashrefs, each hashref representing one entry in the queue as reported by mailq. Valid arguments are: spool - a hashref of { queue_id -> spool_name } pairs if given, this will be used to attempt to indicate in which spool messages currently are; it is not entirely reliable (race!) parse_block my $entry = Mailq->parse_block(@lines); Given all the lines in a single entry's block of lines in mailq output, this returns data about the entry. AUTHOR
Ricardo SIGNES <rjbs@cpan.org> COPYRIGHT AND LICENSE
This software is copyright (c) 2008 by Ricardo SIGNES. This is free software; you can redistribute it and/or modify it under the same terms as perl itself. perl v5.10.1 2008-10-23 Postfix::Parse::Mailq(3pm)
All times are GMT -4. The time now is 02:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy