<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic running shell scrit form C++ in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/running-shell-scrit-form-c/m-p/4979956#M99702</link>
    <description>Hi ,&lt;BR /&gt;&lt;BR /&gt;I have to run a shell scipt form my C++ file and get the output obtained by running the script in my cpp file.&lt;BR /&gt;Can any one throw some light as to how to do this&lt;BR /&gt;&lt;BR /&gt;Thanks in advance&lt;BR /&gt;regards&lt;BR /&gt;Binu</description>
    <pubDate>Fri, 19 May 2006 11:34:46 GMT</pubDate>
    <dc:creator>msbinu</dc:creator>
    <dc:date>2006-05-19T11:34:46Z</dc:date>
    <item>
      <title>running shell scrit form C++</title>
      <link>https://community.hpe.com/t5/operating-system-linux/running-shell-scrit-form-c/m-p/4979956#M99702</link>
      <description>Hi ,&lt;BR /&gt;&lt;BR /&gt;I have to run a shell scipt form my C++ file and get the output obtained by running the script in my cpp file.&lt;BR /&gt;Can any one throw some light as to how to do this&lt;BR /&gt;&lt;BR /&gt;Thanks in advance&lt;BR /&gt;regards&lt;BR /&gt;Binu</description>
      <pubDate>Fri, 19 May 2006 11:34:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/running-shell-scrit-form-c/m-p/4979956#M99702</guid>
      <dc:creator>msbinu</dc:creator>
      <dc:date>2006-05-19T11:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: running shell scrit form C++</title>
      <link>https://community.hpe.com/t5/operating-system-linux/running-shell-scrit-form-c/m-p/4979957#M99703</link>
      <description>Hi Binu, &lt;BR /&gt;&lt;BR /&gt;Have you tried using "system()" call ? I think, it should be helpful to you&lt;BR /&gt;&lt;BR /&gt;-Arun</description>
      <pubDate>Fri, 19 May 2006 11:46:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/running-shell-scrit-form-c/m-p/4979957#M99703</guid>
      <dc:creator>Arunvijai_4</dc:creator>
      <dc:date>2006-05-19T11:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: running shell scrit form C++</title>
      <link>https://community.hpe.com/t5/operating-system-linux/running-shell-scrit-form-c/m-p/4979958#M99704</link>
      <description>The system() function is not a wise choice as the only thing returned is the exit status of the command. You really want to open a pipe for reading via popen() to capture the output of a shell script. pclose() will return the exit status of the command. Man popen, pclose for details.</description>
      <pubDate>Fri, 19 May 2006 12:29:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/running-shell-scrit-form-c/m-p/4979958#M99704</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-05-19T12:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: running shell scrit form C++</title>
      <link>https://community.hpe.com/t5/operating-system-linux/running-shell-scrit-form-c/m-p/4979959#M99705</link>
      <description>And make sure that *all* of your scripts have the interpreter listed in line 1. Scripts will run without this line but only under specific circumstances. The line looks like this:&lt;BR /&gt; &lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt; &lt;BR /&gt;(or ksh or csh or perl....whatever)&lt;BR /&gt;Without that line, there is no way to know how to run the script (scripts always require an interpreter, typically a shell or scripting language amd the C program is not a shell)</description>
      <pubDate>Fri, 19 May 2006 12:57:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/running-shell-scrit-form-c/m-p/4979959#M99705</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2006-05-19T12:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: running shell scrit form C++</title>
      <link>https://community.hpe.com/t5/operating-system-linux/running-shell-scrit-form-c/m-p/4979960#M99706</link>
      <description>hi Binu,&lt;BR /&gt;&lt;BR /&gt;You can use "sprintf" function&lt;BR /&gt;&lt;BR /&gt;eg.&lt;BR /&gt;(void)sprintf(cmd, "cat /proc/iomem 2&amp;gt;/dev/null", idedb[i].device); &lt;BR /&gt;&lt;BR /&gt;and you can use "popen" function &lt;BR /&gt;&lt;BR /&gt;if ((fp = (FILE *)popen("cat /proc/iomem 2&amp;gt;/dev/null", "r")) == NULL) {&lt;BR /&gt;      error ("popen failed when trying to view iomem data");&lt;BR /&gt;      return (1);&lt;BR /&gt;   }&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.phim.unibe.ch/comp_doc/c_manual/C/FUNCTIONS/popen.html" target="_blank"&gt;http://www.phim.unibe.ch/comp_doc/c_manual/C/FUNCTIONS/popen.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Sung</description>
      <pubDate>Fri, 19 May 2006 13:38:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/running-shell-scrit-form-c/m-p/4979960#M99706</guid>
      <dc:creator>Sung Oh</dc:creator>
      <dc:date>2006-05-19T13:38:12Z</dc:date>
    </item>
    <item>
      <title>Re: running shell scrit form C++</title>
      <link>https://community.hpe.com/t5/operating-system-linux/running-shell-scrit-form-c/m-p/4979961#M99707</link>
      <description>WRONG:&lt;BR /&gt;(void)sprintf(cmd, "cat /proc/iomem 2&amp;gt;/dev/null", idedb[i].device); &lt;BR /&gt;&lt;BR /&gt;The sprintf command by itself will do nothing except build the string "cmd" that might later be used in a system(cmd) function or a popen(cmd,"r").</description>
      <pubDate>Fri, 19 May 2006 22:04:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/running-shell-scrit-form-c/m-p/4979961#M99707</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-05-19T22:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: running shell scrit form C++</title>
      <link>https://community.hpe.com/t5/operating-system-linux/running-shell-scrit-form-c/m-p/4979962#M99708</link>
      <description>Thanks all for your help</description>
      <pubDate>Thu, 25 May 2006 08:54:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/running-shell-scrit-form-c/m-p/4979962#M99708</guid>
      <dc:creator>msbinu</dc:creator>
      <dc:date>2006-05-25T08:54:12Z</dc:date>
    </item>
  </channel>
</rss>

