<?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: Doesn't execute the command in my init script? in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/doesn-t-execute-the-command-in-my-init-script/m-p/3566158#M18170</link>
    <description>Could you provide result of :&lt;BR /&gt;ls -l /etc/rc3.d/S98jabber_init&lt;BR /&gt;&lt;BR /&gt;Also, you could redirect output at end of lines :&lt;BR /&gt;/bin/touch /root/karthik.txt &amp;gt;&amp;gt;/tmp/logfile 2&amp;gt;&amp;amp;1&lt;BR /&gt;/bin/chmod 777 /root/karthik.txt &amp;gt;&amp;gt;/tmp/logfile 2&amp;gt;&amp;amp;1&lt;BR /&gt;It will show you in /tmp/logfile what's happening (if something happens). Maybe at execution time, script doesn't have permission to write to /root (it may be launched by bin user, not by root).&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Fred&lt;BR /&gt;</description>
    <pubDate>Fri, 17 Jun 2005 11:51:22 GMT</pubDate>
    <dc:creator>Fred Ruffet</dc:creator>
    <dc:date>2005-06-17T11:51:22Z</dc:date>
    <item>
      <title>Doesn't execute the command in my init script?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doesn-t-execute-the-command-in-my-init-script/m-p/3566157#M18169</link>
      <description>Hello All,&lt;BR /&gt;&lt;BR /&gt;I wrote the following script and saved it in /etc/init.d/ directory as jabber_init:&lt;BR /&gt;&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;#&lt;BR /&gt;# Setting Configuration&lt;BR /&gt;#&lt;BR /&gt;# chkconfig: 3 98 1&lt;BR /&gt;# description: Setting Jabber Configuration&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;start() {&lt;BR /&gt;        /bin/touch /root/karthik.txt&lt;BR /&gt;        /bin/chmod 777 /root/karthik.txt&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;stop() {&lt;BR /&gt;        exit 0;&lt;BR /&gt;}&lt;BR /&gt;and added it to boot-up sequence using the following steps:&lt;BR /&gt;1. chkconfig jabber_init --add&lt;BR /&gt;which created file called S98jabber_init in /etc/rc3.d folder&lt;BR /&gt;2.  chkconfig --list jabber_init&lt;BR /&gt;jabber_init     0:off   1:off   2:off    3:on    4:off    5:off    6:off&lt;BR /&gt;3. The file permissions of /etc/init.d/jabber_init is below:&lt;BR /&gt;ll /etc/init.d/jabber_init&lt;BR /&gt;-rwxr-xr-x    1 root     root          229 Jun 17 20:36 /etc/init.d/jabber_init&lt;BR /&gt;&lt;BR /&gt;When I rebooted the machine, syslog told that jabber_init succeeded:&lt;BR /&gt;Jun 17 20:39:15 symlin5 rc: Starting jabber_init:  succeeded&lt;BR /&gt;&lt;BR /&gt;But the file /root/karthik.txt didn't got created and the chmod command didn't worked.&lt;BR /&gt;&lt;BR /&gt;Any clues/pointers would be helpful. I'm a newbie to SysAdmin. I checked the internet, googled a bit, but couldn't get any clues.&lt;BR /&gt;&lt;BR /&gt;The system I am using is:&lt;BR /&gt;Red Hat Enterprise Linux AS release 3 (Taroon Update 3)&lt;BR /&gt;&lt;BR /&gt;Thanks &amp;amp; Regards,&lt;BR /&gt;Karthik D&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Jun 2005 11:09:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doesn-t-execute-the-command-in-my-init-script/m-p/3566157#M18169</guid>
      <dc:creator>Karthik Dathathri_1</dc:creator>
      <dc:date>2005-06-17T11:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: Doesn't execute the command in my init script?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doesn-t-execute-the-command-in-my-init-script/m-p/3566158#M18170</link>
      <description>Could you provide result of :&lt;BR /&gt;ls -l /etc/rc3.d/S98jabber_init&lt;BR /&gt;&lt;BR /&gt;Also, you could redirect output at end of lines :&lt;BR /&gt;/bin/touch /root/karthik.txt &amp;gt;&amp;gt;/tmp/logfile 2&amp;gt;&amp;amp;1&lt;BR /&gt;/bin/chmod 777 /root/karthik.txt &amp;gt;&amp;gt;/tmp/logfile 2&amp;gt;&amp;amp;1&lt;BR /&gt;It will show you in /tmp/logfile what's happening (if something happens). Maybe at execution time, script doesn't have permission to write to /root (it may be launched by bin user, not by root).&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Fred&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Jun 2005 11:51:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doesn-t-execute-the-command-in-my-init-script/m-p/3566158#M18170</guid>
      <dc:creator>Fred Ruffet</dc:creator>
      <dc:date>2005-06-17T11:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: Doesn't execute the command in my init script?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doesn-t-execute-the-command-in-my-init-script/m-p/3566159#M18171</link>
      <description>I don't see a PATH variable set.&lt;BR /&gt;&lt;BR /&gt;If you don't set a PATH variable, the command you think should be executing may not be executing, leading to no file creation.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Fri, 17 Jun 2005 12:02:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doesn-t-execute-the-command-in-my-init-script/m-p/3566159#M18171</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2005-06-17T12:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: Doesn't execute the command in my init script?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doesn-t-execute-the-command-in-my-init-script/m-p/3566160#M18172</link>
      <description>Fred:&lt;BR /&gt;Thanks for your reply.&lt;BR /&gt;&lt;BR /&gt;1. ls -l /etc/rc3.d/S98jabber_init&lt;BR /&gt;lrwxrwxrwx    1 root     root           21 Jun 17 20:36 /etc/rc3.d/S98jabber_init -&amp;gt; ../init.d/jabber_init&lt;BR /&gt;&lt;BR /&gt;2. I did the changes to the script. But nothing got writtent to /tmp/logfile.&lt;BR /&gt;   ls -l for tmp&lt;BR /&gt;drwxrwxrwt    6 root     root         4096 Jun 17 22:25 tmp&lt;BR /&gt;&lt;BR /&gt;3. Below are contents of /tmp&lt;BR /&gt;   total 8&lt;BR /&gt;-rwxrwxrwx    1 root     root            0 Jun 17 22:22 logfile&lt;BR /&gt;drwx------    2 root     root         4096 Oct 15  2004 orbit-root&lt;BR /&gt;drwx------    2 root     root         4096 Oct 15  2004 ssh-hPue3517&lt;BR /&gt;&lt;BR /&gt;  I created the logfile in temp using touch /tmp/logfile and did chmod 777 logfile before rebooting the system.&lt;BR /&gt;&lt;BR /&gt;SEP:&lt;BR /&gt;What PATH variable needs to be set? I don't understand.&lt;BR /&gt;&lt;BR /&gt;Thanks &amp;amp; Regards,&lt;BR /&gt;Karthik D&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Jun 2005 12:10:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doesn-t-execute-the-command-in-my-init-script/m-p/3566160#M18172</guid>
      <dc:creator>Karthik Dathathri_1</dc:creator>
      <dc:date>2005-06-17T12:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: Doesn't execute the command in my init script?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doesn-t-execute-the-command-in-my-init-script/m-p/3566161#M18173</link>
      <description>Try adding the following to your script and see whether it solves your problem&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;. /etc/init.d/functions&lt;BR /&gt;&lt;BR /&gt;remember the beginning dot is important&lt;BR /&gt;&lt;BR /&gt;Hope this helps,&lt;BR /&gt;Gopi</description>
      <pubDate>Fri, 17 Jun 2005 12:12:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doesn-t-execute-the-command-in-my-init-script/m-p/3566161#M18173</guid>
      <dc:creator>Gopi Sekar</dc:creator>
      <dc:date>2005-06-17T12:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: Doesn't execute the command in my init script?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doesn-t-execute-the-command-in-my-init-script/m-p/3566162#M18174</link>
      <description>Hi Karthik,&lt;BR /&gt;&lt;BR /&gt;the way you have written your scrit it only has two routines but no one are been called, so ... nothing are executed.&lt;BR /&gt;&lt;BR /&gt;To have the start routine executed you must put a line at the end just like that&lt;BR /&gt;&lt;BR /&gt;start&lt;BR /&gt;&lt;BR /&gt;Please, if you are a novice in linux and script language and you do not have time to study before implement what you need, try to look a script that exist on /etc/init.d and have it as an example.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;xyko</description>
      <pubDate>Fri, 17 Jun 2005 13:17:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doesn-t-execute-the-command-in-my-init-script/m-p/3566162#M18174</guid>
      <dc:creator>xyko_1</dc:creator>
      <dc:date>2005-06-17T13:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: Doesn't execute the command in my init script?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doesn-t-execute-the-command-in-my-init-script/m-p/3566163#M18175</link>
      <description>Hi xyko,&lt;BR /&gt;Thanks for your time and reply. Your suggestion really worked. Thanks once again to this forum members for helping newbies like me.&lt;BR /&gt;&lt;BR /&gt;As an acknowledgement, I had assigned 10 points to xyko.&lt;BR /&gt;&lt;BR /&gt;Thanks &amp;amp; Regards,&lt;BR /&gt;Karthik</description>
      <pubDate>Sun, 19 Jun 2005 08:08:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doesn-t-execute-the-command-in-my-init-script/m-p/3566163#M18175</guid>
      <dc:creator>Karthik Dathathri_1</dc:creator>
      <dc:date>2005-06-19T08:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Doesn't execute the command in my init script?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doesn-t-execute-the-command-in-my-init-script/m-p/3566164#M18176</link>
      <description>A better solution is to use a case statement ( or chain of if statements ) to determine whether the arguments passed to your script are proper and then make the correct choice after that.  If you just call the bash functions within your script, ie:&lt;BR /&gt;&lt;BR /&gt;start() &lt;BR /&gt;{ touch /tmp/foo }&lt;BR /&gt;stop()&lt;BR /&gt;{ rm /tmp/foo }&lt;BR /&gt;&lt;BR /&gt;start&lt;BR /&gt;stop&lt;BR /&gt;&lt;BR /&gt;then regardless of the arguments passed to the script you will run both of the functions.  Add lines like this after your functions to make the your script choose the correct action:&lt;BR /&gt;&lt;BR /&gt;case "$1" in&lt;BR /&gt;  start)&lt;BR /&gt;        start&lt;BR /&gt;        ;;&lt;BR /&gt;  stop)&lt;BR /&gt;        stop&lt;BR /&gt;        ;;&lt;BR /&gt;  *)&lt;BR /&gt;        echo 'Usage: scriptname (start|stop)'&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;Most init scripts are setup similarly.&lt;BR /&gt;&lt;BR /&gt;--Dave</description>
      <pubDate>Mon, 20 Jun 2005 11:48:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doesn-t-execute-the-command-in-my-init-script/m-p/3566164#M18176</guid>
      <dc:creator>Dave Falloon</dc:creator>
      <dc:date>2005-06-20T11:48:13Z</dc:date>
    </item>
    <item>
      <title>Re: Doesn't execute the command in my init script?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/doesn-t-execute-the-command-in-my-init-script/m-p/3566165#M18177</link>
      <description>Hi Everybody,&lt;BR /&gt;&lt;BR /&gt;I didn't say to Karthik that putting a start command at the end of the script will correct the script at all. It was only a way to show him why nothing was happening when the script was executed. At the end of my post I suggest him to look at a script in /etc/init.d to see how to write a script to initiate some kind of service because I understood that he does not have good knowledge of script language.&lt;BR /&gt;&lt;BR /&gt;Regards to all,&lt;BR /&gt;Xyko</description>
      <pubDate>Mon, 20 Jun 2005 12:16:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/doesn-t-execute-the-command-in-my-init-script/m-p/3566165#M18177</guid>
      <dc:creator>xyko_1</dc:creator>
      <dc:date>2005-06-20T12:16:35Z</dc:date>
    </item>
  </channel>
</rss>

