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

NAME
Parse::ErrorString::Perl - Parse error messages from the perl interpreter VERSION
version 0.15 SYNOPSIS
use Parse::ErrorString::Perl; my $parser = Parse::ErrorString::Perl->new; # or: my $parser = Parse::ErrorString::Perl->new(lang => 'FR') # to get localized explanations my @errors = $parser->parse_string($string_containing_stderr_output); foreach my $error(@errors) { print 'Captured error message "' . $error->message . '" in file ' . $error->file . ' on line ' . $error->line . " "; } METHODS
new(lang => $lang) Constructor. Receives an optional "lang" parameter, specifying that error explanations need to be delivered in a language different from the default (i.e. English). Will try to load "POD2::$lang::perldiag". parse_string($string) Receives an error string generated from the perl interpreter and attempts to parse it into a list of "Parse::ErrorString::Perl::ErrorItem" objects providing information for each error. SEE ALSO
splain ACKNOWLEDGEMENTS
Part of this module is based on code from splain. BUGS
Please report any bugs or feature requests to "bug-parse-errorstring-perl at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Parse-ErrorString-Perl>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. SUPPORT
You can find documentation for this module with the perldoc command. perldoc Parse::ErrorString::Perl o RT: CPAN's request tracker <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Parse-ErrorString-Perl> o AnnoCPAN: Annotated CPAN documentation <http://annocpan.org/dist/Parse-ErrorString-Perl> o CPAN Ratings <http://cpanratings.perl.org/d/Parse-ErrorString-Perl> o Search CPAN <http://search.cpan.org/dist/Parse-ErrorString-Perl/> AUTHORS
o Petar Shangov, "<pshangov at yahoo.com>" o Gabor Szabo <http://szabgab.com/> o Ahmad M. Zawawi <ahmad.zawawi@gmail.com> COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Petar Shangov. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.10.1 2010-11-29 Parse::ErrorString::Perl(3pm)
All times are GMT -4. The time now is 12:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy