LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices



Reply
 
Search this Thread
Old 03-01-2013, 05:35 AM   #1
Didier Spaier
Senior Member
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slackware{,64}-{14.1,current} on a Lenovo Thinkpad W520
Posts: 4,676

Rep: Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239
How-to set a parameter in the command line to be used later by a user-space script?


I understand that in the boot command line I can set parameters for the kernel and for kernel modules.

In addition, is it possible to set in the boot command line a parameter for a user space program or script?

For instance would it be possible to write something like "export LANG=fr" to be passed to some shell script after init or even rc.S is started?

Last edited by Didier Spaier; 03-01-2013 at 11:03 AM.
 
Old 03-01-2013, 08:08 AM   #2
elucches
Member
 
Registered: Jan 2011
Posts: 91

Rep: Reputation: 8
You mean you can't use /etc/rc.local nor .bashrc?
 
Old 03-01-2013, 09:03 AM   #3
a31amit
LQ Newbie
 
Registered: Feb 2013
Location: /root
Distribution: RHEL CENTOS UBUNUTU
Posts: 7

Rep: Reputation: 1
Here is the way :

Add your parameters in kernel line :

Code:
kernel /vmlinuz-2.6.18-308.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet myvalue=25
This will you can find in "/proc/cmdline" file while booting or after booting linux

Code:
[root@a31amit ~]# cat /proc/cmdline
ro root=/dev/VolGroup00/LogVol00 rhgb quiet myvalue=25
for getting values in script, you can use below mentioned code.
Code:
for params in $(cat /proc/cmdline); do
    echo $params | grep -q myvalue ;
    if [ $? == 0 ]; then
        val=$(echo $params | cut -d= -f2);
        echo "myvalue is $val";
    fi;
done
I believe this is what you want to know.
 
1 members found this post helpful.
Old 03-01-2013, 09:11 AM   #4
Didier Spaier
Senior Member
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slackware{,64}-{14.1,current} on a Lenovo Thinkpad W520
Posts: 4,676

Original Poster
Rep: Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239
Quote:
Originally Posted by elucches View Post
You mean you can't use /etc/rc.local nor .bashrc?
Thanks for your answer.

Your question makes me think that I should have given a bit more of context

I am internationalizing Slackware's installer, thus the user should choose in which locale (s)he sees messages during the (text) installation.

There are basically two steps in the process:
(1) isolinux is used to provide the user with the ability of setting parameters in the boot command line, including which kernel to boot with (Incidentally, a that time (s)he can choose to boot an existing system instead of installing, and run testmem).
(2) Linux is booted, then the installation process occurs.

Basically I'd like that something I type in step (1) be used in step (2) so that the choice of UI's language be made really early.

PS I want to provide an internationalized installer, not several localized installers.

Last edited by Didier Spaier; 03-01-2013 at 09:26 AM.
 
Old 03-01-2013, 11:02 AM   #5
Didier Spaier
Senior Member
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slackware{,64}-{14.1,current} on a Lenovo Thinkpad W520
Posts: 4,676

Original Poster
Rep: Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239
Quote:
Originally Posted by a31amit View Post
Here is the way
Yes, that's exactly what I was looking for, Amit, thanks a lot!

PS Oh, and I almost forgot: welcome to LQ.

Last edited by Didier Spaier; 03-01-2013 at 11:05 AM.
 
Old 03-02-2013, 06:40 AM   #6
a31amit
LQ Newbie
 
Registered: Feb 2013
Location: /root
Distribution: RHEL CENTOS UBUNUTU
Posts: 7

Rep: Reputation: 1
@Didier, Thanks a lot
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to pass command-line parameter to shell script? Kropotkin Linux - Newbie 12 07-25-2011 10:24 AM
how to pass response as command parameter? babysoft Linux - Newbie 2 03-11-2010 08:56 AM
pass parameter in command line lingyun Linux - Newbie 4 04-21-2009 11:42 PM
how to pass the parameter to command sed linux_1 Linux - Enterprise 3 10-15-2007 08:10 PM


All times are GMT -5. The time now is 01:37 PM.

Main Menu
Advertisement
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 Google+: linuxquestions
Open Source Consulting | Domain Registration