<?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: Problem with argv in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-argv/m-p/2518803#M871616</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Use sprintf!&lt;BR /&gt;&lt;BR /&gt;--------------------&lt;BR /&gt;int main(int argc, char **argv) {&lt;BR /&gt;...&lt;BR /&gt;char strCommand[256];&lt;BR /&gt;sprintf(strCommand, "/home/My_shell_script.sh %s %s", argv[1], argv[2]);&lt;BR /&gt;system(strCommand);&lt;BR /&gt;...&lt;BR /&gt;}&lt;BR /&gt;-------------------&lt;BR /&gt;&lt;BR /&gt;Hope this helps,&lt;BR /&gt;Rik</description>
    <pubDate>Thu, 19 Apr 2001 08:35:56 GMT</pubDate>
    <dc:creator>RikTytgat</dc:creator>
    <dc:date>2001-04-19T08:35:56Z</dc:date>
    <item>
      <title>Problem with argv</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-argv/m-p/2518802#M871615</link>
      <description>Hello to everyone,&lt;BR /&gt;&lt;BR /&gt;Now my problem is this:&lt;BR /&gt;I have this little script that allows to an user to execute "My_shell_script.sh" &lt;BR /&gt;with root privileges:&lt;BR /&gt;_____________________________________&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;system("/home/My_shell_script.sh");&lt;BR /&gt;} &lt;BR /&gt;_____________________________________&lt;BR /&gt;&lt;BR /&gt;But the script it would have to be run (in enviroment Unix) with two parameters, inserted by the user when he run the script:&lt;BR /&gt;./My_shell_script_compiled $1 $2&lt;BR /&gt;&lt;BR /&gt;So I've tried to modify My_shell_script.sh:&lt;BR /&gt;____________________________________________&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;char * argv[1];&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;system("/home/My_shell_script.sh $argv[1] $argv[2]");&lt;BR /&gt;} &lt;BR /&gt;___________________________________________&lt;BR /&gt;and then run:&lt;BR /&gt;&lt;BR /&gt;./My_shell_script_compiled $1 $2&lt;BR /&gt;&lt;BR /&gt;as another user, but (as I thought)it doesn't work!&lt;BR /&gt;&lt;BR /&gt;Some errors:&lt;BR /&gt;chmod:can't access [1]&lt;BR /&gt;ksh: [2]: Arguments must be %job or process ids&lt;BR /&gt;&lt;BR /&gt;Please forgive my syntax but I'm not C expert&lt;BR /&gt; ;-)&lt;BR /&gt;&lt;BR /&gt;Could you help me?&lt;BR /&gt;Thanks, &lt;BR /&gt;Sergio&lt;/STDIO.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Thu, 19 Apr 2001 08:24:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-argv/m-p/2518802#M871615</guid>
      <dc:creator>Sergio Tancredi</dc:creator>
      <dc:date>2001-04-19T08:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with argv</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-argv/m-p/2518803#M871616</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Use sprintf!&lt;BR /&gt;&lt;BR /&gt;--------------------&lt;BR /&gt;int main(int argc, char **argv) {&lt;BR /&gt;...&lt;BR /&gt;char strCommand[256];&lt;BR /&gt;sprintf(strCommand, "/home/My_shell_script.sh %s %s", argv[1], argv[2]);&lt;BR /&gt;system(strCommand);&lt;BR /&gt;...&lt;BR /&gt;}&lt;BR /&gt;-------------------&lt;BR /&gt;&lt;BR /&gt;Hope this helps,&lt;BR /&gt;Rik</description>
      <pubDate>Thu, 19 Apr 2001 08:35:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-argv/m-p/2518803#M871616</guid>
      <dc:creator>RikTytgat</dc:creator>
      <dc:date>2001-04-19T08:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with argv</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-argv/m-p/2518804#M871617</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;if you only want to run you script you should better use the execlp() call:&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;main(argc,argv)&lt;BR /&gt;int argc;&lt;BR /&gt;char **argv;&lt;BR /&gt;{ &lt;BR /&gt;execlp("/home/My_shell_script.sh", argv); &lt;BR /&gt;} &lt;BR /&gt;&lt;BR /&gt;Other solution for only 2 parameters:&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;main(argc,argv)&lt;BR /&gt;int argc;&lt;BR /&gt;char **argv;&lt;BR /&gt;{ &lt;BR /&gt;  char cmdbuf[1024];&lt;BR /&gt;&lt;BR /&gt;  sprintf(cmdbuf, "/home/My_shell_script.sh %s %s", argv[1], argv[2]);&lt;BR /&gt;  system(cmdbuf); &lt;BR /&gt;} &lt;BR /&gt;&lt;BR /&gt;Regards&lt;/STDIO.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Thu, 19 Apr 2001 08:42:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-argv/m-p/2518804#M871617</guid>
      <dc:creator>Andreas Voss</dc:creator>
      <dc:date>2001-04-19T08:42:51Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with argv</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-argv/m-p/2518805#M871618</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;To Rik: This is the error that I have when compile your script:&lt;BR /&gt;(Bundled) cc: "Myscript.c", line 2: error 1705: Function prototypes are an ANSI feature.&lt;BR /&gt;&lt;BR /&gt;- Probably 'cause I haven't ANSI C on my HP-UX.&lt;BR /&gt;Thanks however.&lt;BR /&gt;&lt;BR /&gt;To Andreas: This is the error that I have when run your first script:&lt;BR /&gt;&lt;BR /&gt;chmod: can't access {?{?{?^{?:{?F{?P{?`{?i{?|{??{??{??{??&lt;BR /&gt;- (???)&lt;BR /&gt;&lt;BR /&gt;Very good instead your second script. It works!&lt;BR /&gt;:-)&lt;BR /&gt;Thank you very much.&lt;BR /&gt;Sergio</description>
      <pubDate>Thu, 19 Apr 2001 09:46:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-argv/m-p/2518805#M871618</guid>
      <dc:creator>Sergio Tancredi</dc:creator>
      <dc:date>2001-04-19T09:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with argv</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-argv/m-p/2518806#M871619</link>
      <description>Sorry,&lt;BR /&gt;&lt;BR /&gt;the mistake at my first code was execlp(..)&lt;BR /&gt;It has to be execvp(...)&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Thu, 19 Apr 2001 11:06:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-argv/m-p/2518806#M871619</guid>
      <dc:creator>Andreas Voss</dc:creator>
      <dc:date>2001-04-19T11:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with argv</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-argv/m-p/2518807#M871620</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;The error you had with my program is that you do not have the ansi c compiler. Use K&amp;amp;R style function prototypes (Andreas's examples) instead.&lt;BR /&gt;&lt;BR /&gt;For the rest, my code should have worked!!&lt;BR /&gt;&lt;BR /&gt;Bye.</description>
      <pubDate>Thu, 19 Apr 2001 11:16:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-argv/m-p/2518807#M871620</guid>
      <dc:creator>RikTytgat</dc:creator>
      <dc:date>2001-04-19T11:16:06Z</dc:date>
    </item>
  </channel>
</rss>

