<?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: shell script question in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/shell-script-question/m-p/3680596#M102853</link>
    <description>Hi Shivkumar,&lt;BR /&gt;&lt;BR /&gt;apart from what has already been stated there is also a difference with regard to  process hierarchy and number of shells; try comparing the output of&lt;BR /&gt;&lt;BR /&gt;$ sh -c "ps -f"&lt;BR /&gt;to the output of&lt;BR /&gt;$ ps -f&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Sample output:&lt;BR /&gt;&lt;BR /&gt;$ ps -f&lt;BR /&gt;     UID   PID  PPID  C    STIME TTY       TIME COMMAND&lt;BR /&gt;     jxk   614 20419  3 12:39:42 pts/tc    0:00 ps -f&lt;BR /&gt;     jxk 20419 20418  0  Nov 28  pts/tc    0:01 -sh&lt;BR /&gt;    root 20418  1163  0  Nov 28  pts/tc    0:00 telnetd&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The COMMAND ps -f has PID 614; the PPID (father of ps -f) is 20419.&lt;BR /&gt;PID 20419 is the shell itself, -sh, in which ps is executed&lt;BR /&gt;PID 20418, telnetd, is the father of -sh&lt;BR /&gt;&lt;BR /&gt;Simple hierarchy for the above:&lt;BR /&gt;telnet&lt;BR /&gt;sh&lt;BR /&gt;ps -f&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;However.....&lt;BR /&gt;$ sh -c "ps -f"&lt;BR /&gt;     UID   PID  PPID  C    STIME TTY       TIME COMMAND&lt;BR /&gt;     jxk   619 20419  2 12:43:38 pts/tc    0:00 sh -c ps -f&lt;BR /&gt;     jxk 20419 20418  1  Nov 28  pts/tc    0:01 -sh&lt;BR /&gt;    root 20418  1163  0  Nov 28  pts/tc    0:00 telnetd&lt;BR /&gt;     jxk   620   619  4 12:43:38 pts/tc    0:00 ps -f&lt;BR /&gt;&lt;BR /&gt;The output order looks confusing; start at&lt;BR /&gt;PID 620, the ps -f command, whose father is&lt;BR /&gt;PID 619, the command sh -c pd -f, whose father is&lt;BR /&gt;PID 20419, -sh whose father is&lt;BR /&gt;PID 20418, telnetd&lt;BR /&gt;&lt;BR /&gt;Hierarchy with extra shell layer:&lt;BR /&gt;telnet&lt;BR /&gt;sh (the already available shell)&lt;BR /&gt;sh (the sh -c shell, extra)&lt;BR /&gt;ps -f (is executed in the sh -c shell)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In the example&lt;BR /&gt; sh -c /home/bigguy/scripts/rose.sh &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;sh -c creates a shell layer, like in the above example, in which rose.sh will be executed.&lt;BR /&gt;However, if rose.sh sh has been properly written, i.e. the first line specifying which shell to use, &lt;BR /&gt; sh -c&lt;BR /&gt; does - in my opinion - not influence how rose.sh is executed.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
    <pubDate>Tue, 29 Nov 2005 07:49:19 GMT</pubDate>
    <dc:creator>john korterman</dc:creator>
    <dc:date>2005-11-29T07:49:19Z</dc:date>
    <item>
      <title>shell script question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-question/m-p/3680593#M102850</link>
      <description>Dear Sirs,&lt;BR /&gt;&lt;BR /&gt;I saw a script running in crontab as:-&lt;BR /&gt;&lt;BR /&gt;sh -c /home/bigguy/scripts/rose.sh &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;The script rose.sh is written in korn shell.&lt;BR /&gt;The above script is running with "sh -c"&lt;BR /&gt;&lt;BR /&gt;I don't understand the significance of "sh -c" option here.&lt;BR /&gt;&lt;BR /&gt;Appreciate any suggestion.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Shiv&lt;BR /&gt;</description>
      <pubDate>Tue, 29 Nov 2005 05:00:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-question/m-p/3680593#M102850</guid>
      <dc:creator>Shivkumar</dc:creator>
      <dc:date>2005-11-29T05:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: shell script question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-question/m-p/3680594#M102851</link>
      <description>Hi Shiv,&lt;BR /&gt;&lt;BR /&gt;-c means that shell reads the command from the file or from the "string". See man sh-posix for -c.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Borislav</description>
      <pubDate>Tue, 29 Nov 2005 05:13:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-question/m-p/3680594#M102851</guid>
      <dc:creator>Borislav Perkov</dc:creator>
      <dc:date>2005-11-29T05:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: shell script question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-question/m-p/3680595#M102852</link>
      <description>sh -c /home/bigguy/scripts/rose.sh means it is reading strings line by line and executing that.&lt;BR /&gt;&lt;BR /&gt;You can run that script as,&lt;BR /&gt;&lt;BR /&gt;# sh -c &amp;lt; /home/bigguy/scripts/rose.sh&lt;BR /&gt;&lt;BR /&gt;Difference is as,&lt;BR /&gt;&lt;BR /&gt;# sh ls&lt;BR /&gt;sh: ls: Execute permission denied.&lt;BR /&gt;# sh -c ls&lt;BR /&gt;... &lt;LISTING&gt;&lt;BR /&gt;&lt;BR /&gt;It is reading ls as script instead of file. If you are not having -c option then it will take next argument as file name and after that as arguments.&lt;BR /&gt;&lt;BR /&gt;hth.&lt;BR /&gt;&lt;BR /&gt;&lt;/LISTING&gt;</description>
      <pubDate>Tue, 29 Nov 2005 05:29:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-question/m-p/3680595#M102852</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-11-29T05:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: shell script question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-question/m-p/3680596#M102853</link>
      <description>Hi Shivkumar,&lt;BR /&gt;&lt;BR /&gt;apart from what has already been stated there is also a difference with regard to  process hierarchy and number of shells; try comparing the output of&lt;BR /&gt;&lt;BR /&gt;$ sh -c "ps -f"&lt;BR /&gt;to the output of&lt;BR /&gt;$ ps -f&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Sample output:&lt;BR /&gt;&lt;BR /&gt;$ ps -f&lt;BR /&gt;     UID   PID  PPID  C    STIME TTY       TIME COMMAND&lt;BR /&gt;     jxk   614 20419  3 12:39:42 pts/tc    0:00 ps -f&lt;BR /&gt;     jxk 20419 20418  0  Nov 28  pts/tc    0:01 -sh&lt;BR /&gt;    root 20418  1163  0  Nov 28  pts/tc    0:00 telnetd&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The COMMAND ps -f has PID 614; the PPID (father of ps -f) is 20419.&lt;BR /&gt;PID 20419 is the shell itself, -sh, in which ps is executed&lt;BR /&gt;PID 20418, telnetd, is the father of -sh&lt;BR /&gt;&lt;BR /&gt;Simple hierarchy for the above:&lt;BR /&gt;telnet&lt;BR /&gt;sh&lt;BR /&gt;ps -f&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;However.....&lt;BR /&gt;$ sh -c "ps -f"&lt;BR /&gt;     UID   PID  PPID  C    STIME TTY       TIME COMMAND&lt;BR /&gt;     jxk   619 20419  2 12:43:38 pts/tc    0:00 sh -c ps -f&lt;BR /&gt;     jxk 20419 20418  1  Nov 28  pts/tc    0:01 -sh&lt;BR /&gt;    root 20418  1163  0  Nov 28  pts/tc    0:00 telnetd&lt;BR /&gt;     jxk   620   619  4 12:43:38 pts/tc    0:00 ps -f&lt;BR /&gt;&lt;BR /&gt;The output order looks confusing; start at&lt;BR /&gt;PID 620, the ps -f command, whose father is&lt;BR /&gt;PID 619, the command sh -c pd -f, whose father is&lt;BR /&gt;PID 20419, -sh whose father is&lt;BR /&gt;PID 20418, telnetd&lt;BR /&gt;&lt;BR /&gt;Hierarchy with extra shell layer:&lt;BR /&gt;telnet&lt;BR /&gt;sh (the already available shell)&lt;BR /&gt;sh (the sh -c shell, extra)&lt;BR /&gt;ps -f (is executed in the sh -c shell)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In the example&lt;BR /&gt; sh -c /home/bigguy/scripts/rose.sh &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;sh -c creates a shell layer, like in the above example, in which rose.sh will be executed.&lt;BR /&gt;However, if rose.sh sh has been properly written, i.e. the first line specifying which shell to use, &lt;BR /&gt; sh -c&lt;BR /&gt; does - in my opinion - not influence how rose.sh is executed.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Tue, 29 Nov 2005 07:49:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-question/m-p/3680596#M102853</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2005-11-29T07:49:19Z</dc:date>
    </item>
  </channel>
</rss>

