LinuxQuestions.org
Support LQ: Use code LQCO20 and save 20% on CrossOver Office
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 04-26-2004, 07:43 AM   #1
Onyx^
Member
 
Registered: Aug 2003
Location: Cornwall, UK
Distribution: Debian / Red Hat 7.3 / Peewee / Feather
Posts: 56

Rep: Reputation: 15
Shell Scripting Question


Hi all,

I need help with some bash shell scripting questions.. I wonder if any of you could help me... it would be greatly appreciated.

I am trying to write a script that resides in /etc/rcS.d/ that will run during bootup and perform various operations before the network drivers are loaded.

My script 05init_sys is being executed fine.

What I would like within this script is for an action to be performed if the user presses a certain key (for example 'x') during a 5 second delay... If no key is pressed it just continues anyway.

Using a scripting read command causes the system to wait forever until a key is pressed.

Is there a way of acheiving this within bash scripting... ?

Thanks in advance for any help

Ashley Rolleston
 
Old 04-26-2004, 07:51 AM   #2
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 56
As usual, the Advanced Bash Scripting Guide comes to the rescue.


Håkan
 
Old 04-26-2004, 08:04 AM   #3
Onyx^
Member
 
Registered: Aug 2003
Location: Cornwall, UK
Distribution: Debian / Red Hat 7.3 / Peewee / Feather
Posts: 56

Original Poster
Rep: Reputation: 15
thanks hw-tph
 
Old 04-27-2004, 09:15 AM   #4
Onyx^
Member
 
Registered: Aug 2003
Location: Cornwall, UK
Distribution: Debian / Red Hat 7.3 / Peewee / Feather
Posts: 56

Original Poster
Rep: Reputation: 15
OK well I have my desired switch working thanks... but now I have another question

I have be able to keep configuration type information (such as IP address etc) in a seperate file, and then get this information from the file during bootup for use in setting up the boot processes (IP for network drivers)

So I have my 05_initsys script which contains the command to run my seperate configuration script. The variable which is set in the configuration script cannot be used back in 05_initsys however

I am guessing this is because when the config script is run it is a child process so that the main script cannot have the variable exported back to it ?

My question is... how can I extract information from a seperate file whilst running a script during startup?

One problem is that I don't have AWK on my embedded system....

Any ideas would be appreciated,

Thanks,

Ashley Rolleston
 
Old 04-27-2004, 10:05 AM   #5
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 56
You can use the source (no, this is not me making a Star Wars vs open source joke, but it could be) builtin to parse the contents of another file.

Say you have a file called conf with a couple of variables set (I only use one here, but this file could be a whole script):
Code:
string="This is a configuration string or something"
...and in my program I check if the config file is there, and if it is, I source it:
Code:
#!/bin/bash
if [ -f ./conf ]
then
        source ./conf
else
        echo "No configuration file found, aborting. :-("
        exit 1
fi
# Use the variable(s) we sourced from the "conf" file
echo $string
exit 0
You should download the tarball of the ABS Guide, it's invaluable, at least to me.


Håkan

Last edited by hw-tph; 04-27-2004 at 10:06 AM.
 
Old 04-27-2004, 10:37 AM   #6
Onyx^
Member
 
Registered: Aug 2003
Location: Cornwall, UK
Distribution: Debian / Red Hat 7.3 / Peewee / Feather
Posts: 56

Original Poster
Rep: Reputation: 15
thanks once again hw-tph, I will give it a quick try.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
a shell-scripting question: mrchaos Slackware 3 09-22-2005 11:00 AM
Shell scripting question. dragin33 Linux - General 2 08-11-2004 05:17 PM
Shell Scripting Question b_vasu Linux - Newbie 1 11-21-2003 02:10 PM
Shell Scripting Question jester_69 Programming 13 11-05-2003 06:55 PM
Shell Scripting Question chrisk5527 Linux - General 12 07-09-2003 03:36 PM


All times are GMT -5. The time now is 08:50 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration