<?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 Re: Can we execute more than one command with popen() ? in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/can-we-execute-more-than-one-command-with-popen/m-p/4153870#M63663</link>
    <description>Cool, I get the same error as you when I use that directory.&lt;BR /&gt;&lt;BR /&gt;I'll have a little play now!</description>
    <pubDate>Mon, 03 Mar 2008 07:37:52 GMT</pubDate>
    <dc:creator>Mark Grant</dc:creator>
    <dc:date>2008-03-03T07:37:52Z</dc:date>
    <item>
      <title>Can we execute more than one command with popen() ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/can-we-execute-more-than-one-command-with-popen/m-p/4153867#M63660</link>
      <description>Hi All,&lt;BR /&gt;Can we execute more than one command by using popen() call?&lt;BR /&gt;&lt;BR /&gt;I am gettign an error message When I try to execute the following command&lt;BR /&gt;&lt;BR /&gt;popen("cd /sys/class/scsi_host/host0/device/../driver; pwd", "r").&lt;BR /&gt;&lt;BR /&gt;I am seeing the following error message:&lt;BR /&gt;&lt;BR /&gt;cd: /sys/class/scsi_host/host0/device/../driver: No such file or directory&lt;BR /&gt;&lt;BR /&gt;actually the above command is succesfully executed @ shell prompt but when i try to execute the same command in .c file i am getting the above error.&lt;BR /&gt;&lt;BR /&gt;Can any one debug this?&lt;BR /&gt;&lt;BR /&gt;Your help is appreciated.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Masthan D</description>
      <pubDate>Mon, 03 Mar 2008 06:51:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/can-we-execute-more-than-one-command-with-popen/m-p/4153867#M63660</guid>
      <dc:creator>Masthan</dc:creator>
      <dc:date>2008-03-03T06:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: Can we execute more than one command with popen() ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/can-we-execute-more-than-one-command-with-popen/m-p/4153868#M63661</link>
      <description>Any particular reason you don't just chdir() before your popen()?&lt;BR /&gt;&lt;BR /&gt;However, the error you are getting suggests to me that the shell can't find your directory, not that popen() is failing.&lt;BR /&gt;&lt;BR /&gt;popen() simply passes the string to "/bin/sh" and connects it's standard input and output accordingly.  If the shell returns what you want then you should be able to read it through popen().&lt;BR /&gt;&lt;BR /&gt;I just tried your "cd ...;pwd" string and it works fine.&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Mon, 03 Mar 2008 07:30:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/can-we-execute-more-than-one-command-with-popen/m-p/4153868#M63661</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2008-03-03T07:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: Can we execute more than one command with popen() ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/can-we-execute-more-than-one-command-with-popen/m-p/4153869#M63662</link>
      <description>Hi Mark,&lt;BR /&gt;&lt;BR /&gt;Thanks for quick reply.&lt;BR /&gt;&lt;BR /&gt;Can you try the following command on your linux machine? &lt;BR /&gt;&lt;BR /&gt;popen("cd /sys/class/scsi_host/host0/device/../driver; pwd", "r");&lt;BR /&gt;&lt;BR /&gt;FYI: I am using SLES 10 machine.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Masthan</description>
      <pubDate>Mon, 03 Mar 2008 07:33:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/can-we-execute-more-than-one-command-with-popen/m-p/4153869#M63662</guid>
      <dc:creator>Masthan</dc:creator>
      <dc:date>2008-03-03T07:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: Can we execute more than one command with popen() ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/can-we-execute-more-than-one-command-with-popen/m-p/4153870#M63663</link>
      <description>Cool, I get the same error as you when I use that directory.&lt;BR /&gt;&lt;BR /&gt;I'll have a little play now!</description>
      <pubDate>Mon, 03 Mar 2008 07:37:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/can-we-execute-more-than-one-command-with-popen/m-p/4153870#M63663</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2008-03-03T07:37:52Z</dc:date>
    </item>
    <item>
      <title>Re: Can we execute more than one command with popen() ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/can-we-execute-more-than-one-command-with-popen/m-p/4153871#M63664</link>
      <description>You'll notice this isn't a "popen" problem.&lt;BR /&gt;&lt;BR /&gt;See the difference in these two commands.&lt;BR /&gt;&lt;BR /&gt;sh -c "cd /tmp"&lt;BR /&gt;&lt;BR /&gt;and&lt;BR /&gt;&lt;BR /&gt;sh -c "cd /sys/class/scsi_host/host0/device/../driver"&lt;BR /&gt;&lt;BR /&gt;It should be remembered that /sys isn't a real filesystem as such as is merely an export from the kernel.  This almost certainly has something to do with it but it certainly requires further investigation.</description>
      <pubDate>Mon, 03 Mar 2008 07:41:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/can-we-execute-more-than-one-command-with-popen/m-p/4153871#M63664</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2008-03-03T07:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: Can we execute more than one command with popen() ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/can-we-execute-more-than-one-command-with-popen/m-p/4153872#M63665</link>
      <description>Sorry to start spamming here!&lt;BR /&gt;&lt;BR /&gt;Actually I think it's a combination of symbolic links and the sysfs filesystem.  If you chdir() before popen() it works but you find yourself in the target directory not the symbolic link as such.&lt;BR /&gt;&lt;BR /&gt;IS there another way you can get what you are trying to achieve?</description>
      <pubDate>Mon, 03 Mar 2008 07:46:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/can-we-execute-more-than-one-command-with-popen/m-p/4153872#M63665</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2008-03-03T07:46:59Z</dc:date>
    </item>
  </channel>
</rss>

