I am trying to modify a startup script...
The problem is that i am unable to figure out how to take inputs from the user at the startup screen and proceed with the processing accordingly...
Eg:
$ echo "this is a test" (typically this would produce the output)...
$ echo "this is a test" >/dev/msglog (this is used to produce the same output before shell is initialized)...
Similarly,i wanted to know the equivalent for the read statement!!!!
eg:
$ read x (usually reads <something> to variable x)
How can i incorporate the same at the startup??
So you are trying to do something before the system is started?
Possibly
should work, if not then you could try
or something similar. But in my opinion this is not a good thing.
Yeah something like this, but this is done all the while isnt it??
Eg: During the installation of solaris ,one of the first few screens have this option to choose which type of an installation is to be done!!!
like
solaris express developer edition
solairs exprees
something like that....
And according to what the user types in the corresponding installation starts up...
SO here the case statement will be used(i suppose )...
and again the shell isnt initialised yet..
So in this case how does the proper script be recognised...
If i can know how the user input is read here..that would be enough!!!
I'm not understanding if you want to allow a user to give your script a flag/variable at the command line, or if you want an interactive script with a menu. Either way:
Passing a flag/variable to a script, simplest way, in the script just do:
So, when you run the script on the command line, you'd type:
The elements in the command line are counted much like the elements in an array, so when you type the above command, script.ksh is $0 , myVariable is $1, whatever you'd type after myVariable is $2, etc.. Quick example:
You could use $1 in a case statement for an rc startup script, like this:
In the case of an interactive script, when you present users with choices, much like your example of the Solaris installation, if the choices are many and require many words to explained, echo a numbered menu so the user only has to input a number rather than a whole sentence:
Last edited by System Shock; 03-02-2008 at 12:12 PM..
I have the same opinion. To the kernel, the definition of a daemon is a process with no controlling terminal. Daemons show up with a ? in the tty field on most implementations of ps. When a daemon opens a tty, that tty becomes it's controlling terminal. It is no longer a daemon nor will any child processes be daemons. As one example of the many problems this will cause, if you type a control c on that terminal all processes with that controlling will get an INTR unless they are ignoring that signal.
You can avoid this by forking a subprocess to open the terminal, do the tty io, pass the data back to the parent via a file or pipe, and then exit. You must also ensure that this is completed prior to any login prompt appearing on the terminal.
This is why daemons fork to write a message on the console. Becoming a daemon again is not possible, but with the right sequence of operations including several forks(), a process can arrange for a descendant process to be created as a daemon.
Avoiding the non-daemon trap will still leave the problem that the user must be present at reboot time, but at least the system should be working.
I copied the script from an AskUbuntu post -
#!/bin/bash
### BEGIN INIT INFO
# Provides: tomcat7
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/Stop Tomcat server
### END INIT INFO
... (14 Replies)
Hi all,
I'm writing a script to stop & start oracle:
su - oracle -c "sqlplus / as sysdba" -c "shutdown immediate">> ${log} 2>&1
The {log} refers to the log file. The part in bold gives error:
/usr/sbin/shutdown: Only root can run /usr/sbin/shutdown
Pls suggest how to correct this.
... (5 Replies)
Hello,
I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall:
I regularly need to delete files from many directories.
A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Hi
I need the below script to be started whenever I reboot my aix server ?
#cat cdbegin
/cdirect/cdunix/ndm/bin/cdpmgr -i /cdirect/cdunix/ndm/cfg/cbspsdb01/initparm.cfg
Please suggest how to add this to the startup ? (2 Replies)
Hello there!
I need help.
Everytime I login to my ssh, i see this:
-bash: .export: command not found
-bash: .export: command not found
-bash: .export: command not found
-bash: .export: command not found
any help ?
thanks (0 Replies)
I am using AIX 5.3 in P6 machine.
I have a script "test.sh", when i run it manually it runs properly.
I want to run the script automatically when system starts.
I kept the script in /etc/rc.d/init.d and also in /etc/rc.d/rc2.d but it is not working.
Do i have to write it in inittab instead of... (1 Reply)
Hi,
I want a script to execute as soon as a user logs in(instead of directing to his home directory). i know that i have to mention the path of script in the user's .profile to execute this, but not sure where and what to edit. I just tried and was unsuccesful.
Kindly provide the code that i... (4 Replies)
New in Unix, I am adding a line "route add 57.14.y.y 57.14.x.x" every day after rebooting the system. Where can I add the line so during boot up (the system is re-started every day by design (???) the line is executed? (I tried the /etc/rc2.d/S90 but for some reason the line needs to be added... (2 Replies)