<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Linux Forum &mdash; popen & ftp, чтение ответов сервера]]></title>
	<link rel="self" href="https://linuxforum.ru/extern.php?action=feed&amp;tid=13543&amp;type=atom" />
	<updated>2011-05-19T13:17:17Z</updated>
	<generator>PunBB</generator>
	<id>https://linuxforum.ru/viewtopic.php?id=13543</id>
		<entry>
			<title type="html"><![CDATA[Re: popen & ftp, чтение ответов сервера]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=180928#p180928" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Vlad_Imir пишет:</cite><blockquote><div class="quotebox"><blockquote><p>Если режим равен &quot;w&quot;, то можно писать на стандартный ввод команды, выводя в созданный поток</p></blockquote></div><p>Не могли бы пару строчек кода для моего случая.</p></blockquote></div><p>У меня такой задачи не возникало <img src="https://linuxforum.ru/img/smilies/ab.gif" alt="ab" /></p><p>Первый вариант: <a href="http://www.opennet.ru/openforum/vsluhforumID9/4675.html">http://www.opennet.ru/openforum/vsluhforumID9/4675.html</a>, <a href="http://www.feep.net/fget">http://www.feep.net/fget</a></p><p>Второй вариант: <a href="http://www.opennet.ru/man.shtml?topic=popen&amp;category=3&amp;russian=1">http://www.opennet.ru/man.shtml?topic=p … ;russian=1</a></p><p>The type argument is a pointer to a null-terminated string which must be `r&#039; for reading, `w&#039; for writing, or `r+&#039; for reading and writing.</p><p>Попробуйте указать тип r+.</p>]]></content>
			<author>
				<name><![CDATA[gaal.dev]]></name>
				<uri>https://linuxforum.ru/profile.php?id=17434</uri>
			</author>
			<updated>2011-05-19T13:17:17Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=180928#p180928</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: popen & ftp, чтение ответов сервера]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=180887#p180887" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Если режим равен &quot;w&quot;, то можно писать на стандартный ввод команды, выводя в созданный поток</p></blockquote></div><p>Не могли бы пару строчек кода для моего случая.</p>]]></content>
			<author>
				<name><![CDATA[Vlad_Imir]]></name>
				<uri>https://linuxforum.ru/profile.php?id=17321</uri>
			</author>
			<updated>2011-05-19T08:55:09Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=180887#p180887</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: popen & ftp, чтение ответов сервера]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=180718#p180718" />
			<content type="html"><![CDATA[<p>Насколько понимаю проблема в том, что файл открыт на запись<br /><a href="http://www.linuxlib.ru/manpages/POPEN.3.shtml">http://www.linuxlib.ru/manpages/POPEN.3.shtml</a></p><p>Если режим равен &quot;w&quot;, то можно писать на стандартный ввод команды, выводя в созданный поток. Если режим равен &quot;r&quot;, то можно читать со стандартного вывода команды, вводя из созданного потока. </p><p>&nbsp; &nbsp;1. Типичным является следующий пример:<br /></p><div class="codebox"><pre><code>          char *cmd = &quot;ls *.c&quot;;
          FILE *ptr;
          if ((ptr = popen (cmd, &quot;r&quot;)) != NULL)
            while (fgets (buf, n, ptr)) != NULL)
              (void) printf (&quot;%s&quot;, buf);</code></pre></div><p>На стандартный вывод будут записаны имена всех файлов с расширением .c, принадлежащих текущему каталогу. </p><p>(<a href="http://www.linux.org.ru/forum/development/1413419">http://www.linux.org.ru/forum/development/1413419</a>)</p>]]></content>
			<author>
				<name><![CDATA[gaal.dev]]></name>
				<uri>https://linuxforum.ru/profile.php?id=17434</uri>
			</author>
			<updated>2011-05-18T13:09:25Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=180718#p180718</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: popen & ftp, чтение ответов сервера]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=180668#p180668" />
			<content type="html"><![CDATA[<p>Перенёс в раздел Программирование.</p>]]></content>
			<author>
				<name><![CDATA[Vascom]]></name>
				<uri>https://linuxforum.ru/profile.php?id=5339</uri>
			</author>
			<updated>2011-05-18T11:26:17Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=180668#p180668</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[popen & ftp, чтение ответов сервера]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=178449#p178449" />
			<content type="html"><![CDATA[<p>Мне надо контролировать Ftp процесс.<br /></p><div class="codebox"><pre><code>FILE    *command_pipe = popen(&quot;ftp -i -n -v 10.85.43.26&quot;, &quot;w&quot;);
// здесь проверить - был ли успешный коннект

    fprintf(command_pipe, &quot;user %s %s\n&quot;, account, auth);
    // была ли успешна идентификация

    // итд
    fprintf(command_pipe, &quot;hash 1048576\n&quot;);    
    fprintf(command_pipe, &quot;bin\n&quot;);    
    fprintf(command_pipe, &quot;cd %s\n&quot;, path);    
    fprintf(command_pipe, &quot;put %s\n&quot;, ftp_file.c_str());        
    fprintf(command_pipe, &quot;quit\n&quot;);</code></pre></div><p>Я пытался читать ответы сервера (на терминале отображаются) путем использования<br />fscanf, fgets, getline, но всегда буфер оказывался пустой</p><p>Как прочесть ответы сервера?</p><p>Red Hat Enterprise Linux Server release 5.6 (Tikanga)</p>]]></content>
			<author>
				<name><![CDATA[Vlad_Imir]]></name>
				<uri>https://linuxforum.ru/profile.php?id=17321</uri>
			</author>
			<updated>2011-05-12T11:51:14Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=178449#p178449</id>
		</entry>
</feed>
