Script calling by inittab


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script calling by inittab
# 1  
Old 01-22-2017
Script calling by inittab

Hi to all ,
i wrote a small script and i add it to inittab to start the script during Startup. The script works fine , if i call it from the prompt but if it is call from inittab it is runnng too but it does not recognize system variable like USER , LOGNAME.

Since i running out of ideas i put inside the script source /.cshrc and source /etx/profile and source/etc/enviornment.
But this does not change anything the System variable still unkown

thanks a lot for your help

BTW
i running on AIX 4.3.2.0
# 2  
Old 01-22-2017
Those variables are set during user login and thus are only available in a user session.
During startup, no login shell is executed and no user is logged in (although root might be the owner of the startup processes). So, referring to those variables doesn't make any sense.

Does your crontab provide the @reboot time/date specifier?
This User Gave Thanks to RudiC For This Post:
# 3  
Old 01-22-2017
To help you, we'd have to know a bit more about the script...
Who do you think runs the script in /etc/inittab ?

Let's say it must be oracle, and as we all kmow, oracle will not run like that, it needs loads of env variables set. Is it the case? as of course e.g. LOGNAME cannot be found as the script is launched by ? at boot time, so how do you expect that specific variable to be initialised when no login occured?...

In most cases it the use of su that solves the problem like using
Code:
su -c user4thisapplication /opt/application/somebinary

In case when you need the same environment as in interactive mode ( login) you can use su - <user> at the condition you modified the .profile or whaterver profile you are using to bypass what is not used for batch mode : all that has to do with terminal settings etc... when in batch mode.
This User Gave Thanks to vbe For This Post:
# 4  
Old 01-22-2017
Quote:
Originally Posted by RudiC
Those variables are set during user login and thus are only available in a user session.
During startup, no login shell is executed and no user is logged in (although root might be the owner of the startup processes). So, referring to those variables doesn't make any sense.

Does your crontab provide the @reboot time/date specifier?
Hi RudiC,
Thanks a lot for your reply
Sorry that i do not have much knowledge with AIX , I was not aware that this variables not available at boot up
I will come back to you when I am back in the office to answer your question
Thanks for your help
Kind regards

---------- Post updated at 08:15 PM ---------- Previous update was at 08:06 PM ----------

Quote:
Originally Posted by vbe
To help you, we'd have to know a bit more about the script...
Who do you think runs the script in /etc/inittab ?

Let's say it must be oracle, and as we all kmow, oracle will not run like that, it needs loads of env variables set. Is it the case? as of course e.g. LOGNAME cannot be found as the script is launched by ? at boot time, so how do you expect that specific variable to be initialised when no login occured?...

In most cases it the use of su that solves the problem like using
Code:
su -c user4thisapplication /opt/application/somebinary

In case when you need the same environment as in interactive mode ( login) you can use su - <user> at the condition you modified the .profile or whaterver profile you are using to bypass what is not used for batch mode : all that has to do with terminal settings etc... when in batch mode.
Hi VBE,
Thanks for your reply
I did add the call to my script with mkittab and it works but the problems is with the variables
When I am back in office I will try your recommendation with su
I was expecting it will use root as user
when I login as user root the script works perfect
When back in the office I will post the script and the entry i made in inittab
Thanks for your support
With kind regards
# 5  
Old 01-25-2017
this are part of the file /etc/inittab

Code:
te/httpdlite.conf >/dev/console 2>&1
 : httpd:2:once:/cae1/3rdparty/bin/apachectl start >/dev/null 2>&1
 imqss:2:once:/usr/IMNSearch/bin/imq_start >/dev/console 2>&1
 : adsm::once:/usr/tivoli/tsm/client/ba/bin/dsmc sched > /dev/null 2>&1 #Adsm sc\
 heduler
 sserver:2:wait:/etc/mfg/rc.sserver > /dev/null 2>&1
 tty17:2:off:/usr/sbin/getty /dev/tty17
 tty18:2:off:/usr/sbin/getty /dev/tty18
 ssa:2:once:/simstatus/simstatus


when ich check it it is running with user root acount

Code:
root 13170 1 0 Jan 06 - 8:42 csh /simstatus/simstatus

---------- Post updated at 10:25 PM ---------- Previous update was at 10:09 PM ----------

Hi RudiC,

yes my crontab provide the Option @reboot , but i guest it will the same Problem that the user don''f have his full enviornment because it is in Batch mode. At the Moment it hat the call for my script in inittab , but i will try to put it now in crontab.

Kind regards
Thomas

Last edited by Corona688; 01-25-2017 at 05:19 PM..
# 6  
Old 01-25-2017
OK, so at least we have established you are using AIX. Care to tel us which version? Issue:

Code:
oslevel -s

to display it. Please post the output.

Quote:
Originally Posted by Nadielosabra
Code:
root 13170 1 0 Jan 06 - 8:42 csh /simstatus/simstatus

You should - under absolutely no circumstance - use csh at all. csh is bug-ridden to the extreme and is long deprecated, not to mention non-POSIX. Is there any factual reason why the script is in csh (other than "i didn't bother to learn any other)?

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
# 7  
Old 01-26-2017
Quote:
Originally Posted by bakunin
OK, so at least we have established you are using AIX. Care to tel us which version? Issue:

Code:
oslevel -s

to display it. Please post the output.



You should - under absolutely no circumstance - use csh at all. csh is bug-ridden to the extreme and is long deprecated, not to mention non-POSIX. Is there any factual reason why the script is in csh (other than "i didn't bother to learn any other)?

I hope this helps.

bakunin
Hi Bakunin
Thanks a lot for your reply
I did post the oslevel already at my first post it is AIX 4.3
Thanks for your nice recommendation not to use the c shell ,I don't matter which shelll I am using as long I got the variables when I am in batch mode
That is the only thing I am care about
With kind redgards
Nadielosabra
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

How to add a entry in inittab?

Hi All, I am booting by Linux box with the run level 3 and it gets booted successfully. I want to execute a script once the system is up and running in the run level 3. I was trying to add a entry to /etc/inittab to execute my script once the system is up. I have added the below... (5 Replies)
Discussion started by: kalpeer
5 Replies

2. UNIX for Dummies Questions & Answers

Inittab configuration

I am installing BusyBox on a device that does not have keyboard or serial connection, so I log into the system with SSH. I am in doubt about what to put in the inittab file. This is the content of the file: ::sysinit:/etc/init.d/rcS ::respawn:/bin/login ::shutdown:/sbin/swapoff -a... (1 Reply)
Discussion started by: richard78
1 Replies

3. UNIX for Dummies Questions & Answers

What breaks inittab

Today there was a situation where processes running from inittab was broken. Can someone help me understand, how to find out, who might have stopped those processes? Or how does it get broken? G (2 Replies)
Discussion started by: ggayathri
2 Replies

4. UNIX for Advanced & Expert Users

Does inittab needs system restart?

Hi currently my linux instance is running in runlevel 3 ( someone has set the default to 3) i have to change it to runlevel 5 . my question 1) does the editing of /etc/inittab needs system restart to enter runlevel 5. 2) how can we avoid system restart because if some users are... (3 Replies)
Discussion started by: rakeshkumar
3 Replies

5. Solaris

inittab entry does not works

Hi, I have a solaris 10 server,which has a process running that communicates with other system.I have made following entry in the inittab file. PM15:s12345:respawn:/ncm/bin/communicator PM15 : Unique process ID s12345 : run levels respawn : if anytime the process... (2 Replies)
Discussion started by: asalman.qazi
2 Replies

6. Shell Programming and Scripting

doubt in /etc/inittab script

Hi.. When i was just looking throught /etc/inittab file.. i had stuck with some problems that i dont known in shell scripts Here how the lablel like si ca lo l1 etc works.. do scripts proivide any label features.. please help... thanks in advance esham (3 Replies)
Discussion started by: esham
3 Replies

7. Solaris

inittab in Solaris 10

Hi, In Solaris 9 and below release we are using the rc script in inittab. I don't have much idea abt inittab in Solaris. In Solris 9 and below: We use rc3 script to start up the server. And we run database script before the rc3. os:23:respawn:/etc/init.d/database start >/dev/null 2>&1... (7 Replies)
Discussion started by: kalpeer
7 Replies

8. Shell Programming and Scripting

passing a variables value from the called script to calling script using ksh

How do i get the value of the variable from the called script(script2) to the calling script(script1) in ksh ? I've given portion of the script here to explain the problem. Portion of Script 1 ============= ----- ----- tmp=`a.ksh p1 p2 p3` if then # error processing fi -----... (10 Replies)
Discussion started by: rajarkumar
10 Replies

9. UNIX for Dummies Questions & Answers

inittab solaris

Hi! Is it possible to add more ttys in Solaris, like with inittab in Linux? I want to switch between the ttys with Alt F1+F2+F3 .... like Linux does. How can i do this? (1 Reply)
Discussion started by: donald1111
1 Replies

10. UNIX for Dummies Questions & Answers

I got a corrupt /etc/inittab file....what next?

Hi guys, For some reason a client has given us a Sun Netra T1 with Solaris 8 to administer for them. That's always good business. However, the other day we rebooted the machine and to our amazement, after doing the preliminary hardware tests, we got an error messgae saying that /etc/inittab was... (3 Replies)
Discussion started by: Ivo
3 Replies
Login or Register to Ask a Question