<?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: Problems with exec families in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/problems-with-exec-families/m-p/2501622#M80070</link>
    <description>The first arguement for execl is the pathname of a *FILE* which is to be executed.  This means you need to write&lt;BR /&gt;&lt;BR /&gt;      if (execl("/usr/bin/finger","finger",cadena)&amp;lt;0) {&lt;BR /&gt;          /* ... */&lt;BR /&gt;      }&lt;BR /&gt;&lt;BR /&gt;Also, what is the purpose of the line&lt;BR /&gt;&lt;BR /&gt;      cadena[strlen(cadena)]='\0';&lt;BR /&gt;&lt;BR /&gt;If you can get string length, it is properly null-terminated.  If it is not terminated or terminated, say, at 2040, this line is not going to help.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Fellix</description>
    <pubDate>Tue, 06 Mar 2001 17:40:33 GMT</pubDate>
    <dc:creator>Felix J. Liu</dc:creator>
    <dc:date>2001-03-06T17:40:33Z</dc:date>
    <item>
      <title>Problems with exec families</title>
      <link>https://community.hpe.com/t5/operating-system-linux/problems-with-exec-families/m-p/2501621#M80069</link>
      <description>i wrote this program&lt;BR /&gt;------------------------&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;#include &lt;UNISTD.H&gt;&lt;BR /&gt;#include &lt;ERRNO.H&gt;&lt;BR /&gt;#include &lt;STRING.H&gt;&lt;BR /&gt;int main(int argc, char *argv[])&lt;BR /&gt;{&lt;BR /&gt;  char cadena[2048];&lt;BR /&gt;  sprintf(cadena,"%s",argv[1]);&lt;BR /&gt;  cadena[strlen(cadena)]='\0';&lt;BR /&gt;  printf("finger %s\n",cadena);&lt;BR /&gt;  if (execl("/usr/bin/","finger",cadena)&amp;lt;0)&lt;BR /&gt;  {&lt;BR /&gt;    perror("Creacion:");&lt;BR /&gt;  }&lt;BR /&gt;}&lt;BR /&gt;-----------------------&lt;BR /&gt;but when i running this is the result&lt;BR /&gt;[jruiz@dns cgi]$ a.out jruiz&lt;BR /&gt;finger jruiz&lt;BR /&gt;Creacion:: Permission denied&lt;BR /&gt;[jruiz@dns cgi]$ &lt;BR /&gt;-------------------------&lt;BR /&gt;what is the problem i know i have permition to see myself, is the same problem when the root own the program&lt;/STRING.H&gt;&lt;/ERRNO.H&gt;&lt;/UNISTD.H&gt;&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Tue, 06 Mar 2001 16:44:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/problems-with-exec-families/m-p/2501621#M80069</guid>
      <dc:creator>Jesus Ruiz_1</dc:creator>
      <dc:date>2001-03-06T16:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with exec families</title>
      <link>https://community.hpe.com/t5/operating-system-linux/problems-with-exec-families/m-p/2501622#M80070</link>
      <description>The first arguement for execl is the pathname of a *FILE* which is to be executed.  This means you need to write&lt;BR /&gt;&lt;BR /&gt;      if (execl("/usr/bin/finger","finger",cadena)&amp;lt;0) {&lt;BR /&gt;          /* ... */&lt;BR /&gt;      }&lt;BR /&gt;&lt;BR /&gt;Also, what is the purpose of the line&lt;BR /&gt;&lt;BR /&gt;      cadena[strlen(cadena)]='\0';&lt;BR /&gt;&lt;BR /&gt;If you can get string length, it is properly null-terminated.  If it is not terminated or terminated, say, at 2040, this line is not going to help.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Fellix</description>
      <pubDate>Tue, 06 Mar 2001 17:40:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/problems-with-exec-families/m-p/2501622#M80070</guid>
      <dc:creator>Felix J. Liu</dc:creator>
      <dc:date>2001-03-06T17:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with exec families</title>
      <link>https://community.hpe.com/t5/operating-system-linux/problems-with-exec-families/m-p/2501623#M80071</link>
      <description>#include &lt;STDIO.H&gt; &lt;BR /&gt;#include &lt;STDLIB.H&gt; &lt;BR /&gt;#include &lt;UNISTD.H&gt; &lt;BR /&gt;#include &lt;ERRNO.H&gt; &lt;BR /&gt;#include &lt;STRING.H&gt; &lt;BR /&gt;int main(int argc, char *argv[]) &lt;BR /&gt;{ &lt;BR /&gt;    char cadena[2048];  &lt;BR /&gt;    sprintf(cadena,"%s",argv[1]); &lt;BR /&gt;    cadena[strlen(cadena)]='\0'; &lt;BR /&gt;    printf("finger %s\n",cadena); &lt;BR /&gt;/* the first parameter to any exec is  &lt;BR /&gt; * the name/path of the program you wish to &lt;BR /&gt; * execute, thus:&lt;BR /&gt; * execl("/usr/bin/finger", "finger", cadena);&lt;BR /&gt; */&lt;BR /&gt;    if (execl("/usr/bin/","finger",cadena)&amp;lt;0) &lt;BR /&gt;    { &lt;BR /&gt;      perror("Creacion:"); &lt;BR /&gt;    } &lt;BR /&gt;} &lt;BR /&gt;&lt;BR /&gt;Now ... as for argv[0], which is the second parameter, this is actually passed as a the zeroth argument to the program. While with something like finger it is not evident what the use may be, but some software programs use the zeroth argumnet rather niftily (is that a word yet?)&lt;BR /&gt;&lt;BR /&gt;For example, gzip examines its own name (i.e, contents of argv[0]) and figures out if it is actually being called as 'gzip' or 'gunzip' and accordingly zips or unzips the subsequent arguments.&lt;BR /&gt;&lt;BR /&gt;For instance, the attached example implements a slightly different version of the system utils 'basename' and 'dirname'&lt;/STRING.H&gt;&lt;/ERRNO.H&gt;&lt;/UNISTD.H&gt;&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Wed, 07 Mar 2001 08:06:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/problems-with-exec-families/m-p/2501623#M80071</guid>
      <dc:creator>Ahmed Masud</dc:creator>
      <dc:date>2001-03-07T08:06:38Z</dc:date>
    </item>
  </channel>
</rss>

