On Thu, 2003-04-03 at 07:50, santosh kumar wrote:
> Hi guys,
>
> Have small doubt in bash scripting..(#!/bin/bash)
> Need to write script to get all m/c info, If I do cat /proc/cpuinfo will
> display CPU info.
> My requirement is grep CPU model, speed and display the outputs like
> For example m/c
On Thu, Apr 03, 2003 at 10:57:31AM -0300, Rodrigo Nascimento wrote:
>
> What you want?
I believe that the poster wants our advice on how to obtain the
output he posted.
[EMAIL PROTECTED] seyman]$ cat /proc/cpuinfo | grep -E "MHz|name"
model name : Pentium III (Coppermine)
cpu MHz :
Hi,
I didn't understand.
What is wrong or confused in output for more one CPU?
1st CPU model : pentium III
1st CPU speed : 1.73 GHz
2nd CPU model : pentium IV
2nd CPU speed : 2.4 GHz
The 1st CPU is a PIII with 1.7 Ghz and 2nd CPU is a P4
with 2.4 Ghz.
What you want?
--- santosh kumar <[E
On 19 Mar 2003, will wrote:
> The .bash_logout script is not executing when my system is in run level
If your xterm is not defined as a login shell, it won't execute .bashrc or
.bash_profile, either. You may need to define the xterm as a login shell
to get .bash_logout working.
--
Guvf gntyva
TERM=xterm
COLORTERM=gnome-terminal
BTW -- I've read the man on xdm that recommends using the Xreset script
(e.g., xdm-config: DisplayManager._0.reset=/etc/X11/xdm/TakeConsole) to
run after the users session is terminated. It should contain commands
such as unmounting directories from file servers
what terminal do you use on your X Window..
Quoting will <[EMAIL PROTECTED]>:
> The .bash_logout script is not executing when my system is in run level
> init 5 (Xsession); however, in init 3 it runs fine. Any one know how
> this can be fixed?
>
> Red Hat Linux release 8.0 (Psyche) -- X
[ test ]
then
Dave
-Original Message-
From: R P Herrold [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 05, 2003 12:11 PM
To: [EMAIL PROTECTED]
Subject: RE: Bash script help ?
On Wed, 5 Feb 2003, David Simmons wrote:
> I have noticed in this thread that everyone is puttin
On Wed, 5 Feb 2003, David Simmons wrote:
> I have noticed in this thread that everyone is putting a ";" after their
> tests: if [ test ] ; and for [ test ] ;
>
> When is the ";" required or is it always required after the test in a
> conditional statement?
Ehhh? Not all people do. I never
quot; required or is it always required after the test in a
conditional statement?
Thanks,
Dave Simmons
-Original Message-
From: Raymundo M. Vega [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 05, 2003 11:00 AM
To: [EMAIL PROTECTED]
Subject: Re: Bash script help ?
I think sev
undo M. Vega [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 05, 2003 11:00 AM
To: [EMAIL PROTECTED]
Subject: Re: Bash script help ?
I think several lines are not quite right:
- regular expression in gawk should be inside the {}, but
you will have to pass the argument to gawk.
- next line aft
I think several lines are not quite right:
- regular expression in gawk should be inside the {}, but
you will have to pass the argument to gawk.
- next line after if should be then, it is usually used like
if [ -z "$processid" ] ; then
the script will only echo first time it finds the string,
[EMAIL PROTECTED] wrote:
I'm trying to get a pidof a php script by capturing the path:
like /home/somebody/my_script which will be the first arg. to the bash script
Could anybody tell me what's wrong with this script ?
I'm new to scripting in general so any help would be apreciated !
#!/bin/ba
On Wednesday, February 5, 2003, at 02:24 PM, Jan wrote:
In your awk stmt you search for '1st_arg' rather than the value of the
variable 1st_arg, which would be $1st_arg - or perhaps ${1st_arg}, as
$1 is something else...
Ok ! Thanks !
Lars
--
redhat-list mailing list
unsubscribe mailto:[E
>Jon Haugsand wrote:
>> * [EMAIL PROTECTED]
>>
>>>#!/bin/bash
>>>1st_arg=$1
>>
>> number not allowed in front.
>>
>>
>>>prosesses=`lsof -i`
>>>prosessid=`echo $prosesses | gawk /1st_arg/'{print $2}'`
>>
>> Cannot understand this to work in gawk. In any case, you might do
>> this a lot more e
Jon Haugsand wrote:
* [EMAIL PROTECTED]
#!/bin/bash
1st_arg=$1
number not allowed in front.
prosesses=`lsof -i`
prosessid=`echo $prosesses | gawk /1st_arg/'{print $2}'`
Cannot understand this to work in gawk. In any case, you might do
this a lot more effective:
echo $prosessid
if [ -z
* [EMAIL PROTECTED]
> #!/bin/bash
> 1st_arg=$1
number not allowed in front.
> prosesses=`lsof -i`
> prosessid=`echo $prosesses | gawk /1st_arg/'{print $2}'`
Cannot understand this to work in gawk. In any case, you might do
this a lot more effective:
> echo $prosessid
> if [ -z "$prosessid" ]
mis
[EMAIL PROTECTED] wrote:
I'm trying to get a pidof a php script by capturing the path:
like /home/somebody/my_script which will be the first arg. to the bash script
Could anybody tell me what's wrong with this script ?
I'm new to scripting in general so any help would be apreciated !
#!/bin/ba
On Thu, 9 Jan 2003, David Busby wrote:
> List,
> I've got a bash script, that executes other scripts (wow!) and the sub
> scripts return a value.
> How can I get the parent script to capture that return value? I've been all
> over the BASH manual (more than one hour) and Google, still no luck
David Busby wrote:
Here's the BASH code that I currently have
#!/bin/bash
for YEAR in 2003 2004 2005 2006
do
CMD="./import.php $YEAR"
$CMD
done
#!/bin/bash
for YEAR in $(seq 2003 1 2006)
do
./import.php $YEAR
RETVAL=$?
echo $RETVAL;
done
You can create different RETVALs if you
to the
number of items it imported.
I would like BASH to trap this value and at the end echo the total of the 4
script executions.
/B
- Original Message -
From: "Todd A. Jacobs" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, January 09, 2003 19:39
Subject:
On Thu, 9 Jan 2003, David Busby wrote:
> How can I get the parent script to capture that return value? I've been
> all over the BASH manual (more than one hour) and Google, still no luck.
Not sure what you're really trying to do. If you posted real code, that
would help.
The exit status of th
On Wed, 6 Nov 2002, MET wrote:
> for i in $#
> do echo Loop iteration - $i
> done
What shell? Have you read the appropriate manual? Have you bought the
appropriate O'Reilly book? Is this a homework assignment?
--
"Whenever I feel blue, I start breathing again."
That is what you told it to do :) $# outputs the number of arguments
input to a script. You should look into the shift built-in function of
(ba)sh. Try something like this:
#!/bin/sh
while [ "$1" ]
do
echo $1
shift
done
Check out:
http://www.cyberciti.biz/nixcraft/linux/docs
Replace $# with $* in ur script..
-Original Message-
From: MET [mailto:met@;uberstats.com]
Sent: Wednesday, November 06, 2002 20:07
To: RedHat List
Subject: Bash Script || Loop Through Parameters
I'm trying to loop through all the parameters given to a script. My script
is
executed l
On Wed, 6 Nov 2002, Hella wrote:
> You want to use sed and awk for a truly robust solution.
a sadly-overlooked but useful text processing command is "expr".
$ man expr
which can do simple things like matching, extraction, length,
substr and stuff like that. check it out before going on to sed,
You want to use sed and awk for a truly robust solution.
If you need further help, I can dig up examples of doing this.
Generally, when I need to do text processing, I turn to perl. However,
this can be done in bash, but larger tasks will get ugly in bash.
-Chuck
John H Darrah wrote:
On Mon,
On Mon, 4 Nov 2002, Chad Skinner wrote:
> Is there a way in a bash script to trim the spaces from the front and end of
> a variable
>
> I have a script that contains the following variable definition
>
>
> BLOCKED_SERVICES="tcp,111,Sun RPC;\
> udp,111,Sun RPC;\
>
> -Original Message-
> From: mark
> Subject: Re: Bash Script Question
>
>
> For example, with a datafile, you could then say
> export BLOCKED_SERVICES=`cat myblocked` but where you
> need the services broken out, youi would want to use awk:
>
> # start o
On Tuesday 05 November 2002 09:51 am, Chad is done writ:
> Is there a way in a bash script to trim the spaces from the front and
> end of a variable
> I have a script that contains the following variable definition
> BLOCKED_SERVICES="tcp,111,Sun RPC;\
>udp,111,Sun
you can use xargs to get rid of that whitespace in the protocol declaration:
BLOCKED_SERVICES="tcp,111,Sun RPC;\
udp,111,Sun RPC;\
tcp,443,Microsoft DS;\
udp,443,Microsoft DS"
IFS=";"
for SERVICE in $BLOCKED
On Mon, 4 Nov 2002, Chad Skinner wrote:
> Is there a way in a bash script to trim the spaces from the front and end of
> a variable
Not the way you're doing it. The easiest thing to do is to change your
data representation, rather than spending a lot of time trying to strip
whitespace. Try:
> -Original Message-
> From: Chad Skinner
> Subject: Bash Script Question
>
>
> Is there a way in a bash script to trim the spaces from the
> front and end of a variable
>
> I have a script that contains the following variable definition
>
>
> BLOCKED_SERVICES="tcp,111,Sun RPC;
On Fri, Oct 11, 2002 at 08:05:49PM -0500, Freddy Chavez wrote:
> I've read many examples about using a shell script to test a mail server
> (sendmail, postfix, etc) such as:
> #!/bin/bash
> telnet 1.2.3.4 25 << _EOF_
> HELO abc.com
> <- smtp conversation here (mail from, r
>> Look at manipulating the IFS variable; you can do wondrous things with
that.
Yep, I've thought about it, but that's all so far.
>> Next, we get into opening and using file descriptors...
All in good time. :)
bd
___
Redhat-list mailing list
[EMA
>> See my other replies for more thoughts on this, but it actually has to be
>> "s/$//g", and must use "s rather than 's.
Whoops! My bad. :) Both of these work...
's/\\$//g' # single quotes
"s/$//g"# double quotes
Thanks to Matthew for catching my goof
>> That's making the big assumption that wrong sort of quotes is your
problem.
>> If not then umm.. err.. *shurg* ... Did i meantion in worked for me? ;)
Yep, you nailed it. Thanks for taking time to post the echo examples!
bd
___
Redhat-list maili
On Fri, Jan 26, 2001 at 09:41:30AM -0800, Brad Doster wrote:
> IOW, I can treat the list as space or line delimited. Using var3=`echo
> "$var1\n$var2"` eliminates the ability to treat it as a space delimilted
> list as 'echo $var3' and 'echo "$var3"' both produce 'a\nb'.
Well, in one sense--in a
>> Now what you should do is store the \n's in var3 like:
>> var3=`echo "$var1\n$var2"`
>> after which:
>> echo -e $var3
>> would give the desired output
Yep, that works too. But :), var3=`echo -e "$var1\n$var2"` seems to be a
bit more flexible in that 'echo $var3' produces...
a b
...a
>> varlist=`echo "$varlist" | sed 's/\\$//'`
See my other replies for more thoughts on this, but it actually has to be
"s/$//g", and must use "s rather than 's.
Thanks for your input!
bd
___
Redhat-list mailing list
[EMAIL PROTECTED]
https://li
=
Brad Doster
Insight Network Solutions
www.InsightNetSolutions.net
925.335.9510
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Luke C Gavel
Sent: Friday, January 26, 2001 2:18 AM
To: [EMAIL PROTECTED]
Subject: RE: Bash Script Questions
On Fri, 26 Jan 2001 at 8:34am (-0800), Brad Doster wrote:
> >> Ahhh.. we need another \ - one to protect $ from sed and
> >> another to protect the first \ from the backticks.
>
> >>varlist=`echo "$varlist" | sed 's/\\$//g'`
>
> Apparently that's still not enough. I think '\\$' parses to '\$
-Original Message-
From: Matthew Melvin [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 25, 2001 9:57 PM
To: Brad Doster
Cc: [EMAIL PROTECTED]
Subject: RE: Bash Script Questions
On Thu, 25 Jan 2001 at 7:56pm (-0800), Brad Doster wrote:
> Hi Matthew,
>
> Perhaps what I'm do
>> var3=`echo -e "$var1\n$var2"`
>>...does the trick.
It's the -e option in echo that's doing this, it allows the \n to be
read and used as a new line. e.g. echo -e "$var1\n$var2" should
read:
a
b
but echo var3 after above would still give:
a b
Now what you should do is store the \n's in v
probably a bit late with this but;
> > varlist=`echo "$varlist" | sed 's/$//'`
>
varlist=`echo "$varlist" | sed 's/\\$//'`
> > 2) Given two variables, say var1="a" and var2="b", I want to create var3
> > such that it is "ab", i.e 'echo "$var3"' produces:
> >
> > a
> > b
> >
>
You w
On Thu, 25 Jan 2001, Brad Doster wrote:
> But why? Why doesn't good ol' '\$' work right out of the
> box?
Because the '$' is used in a special by the shell (script) and
sed too. sed uses the '$' to anchor a search pattern from the
end of a line, and, of course the script uses it to expand
vari
On Thu, 25 Jan 2001 at 7:56pm (-0800), Brad Doster wrote:
> Hi Matthew,
>
> Perhaps what I'm doing in the '$' case needs a bit more explanation. The
> following is a script segment that gleans variable names from the script in
> which it is run:
>
> for varname in case select until while
>> varlist=`echo "$varlist" | sed -e "s/$//g"
Yep, that did it! But, what did it do? Or, where can I find info that will
help me make sense of it? FWIW, it looks to me like it's searching for
'\\$' (???). Oooh it is! But the '\\$' gets reduced to '\$' which then
works as desired.
Hi Matthew,
Perhaps what I'm doing in the '$' case needs a bit more explanation. The
following is a script segment that gleans variable names from the script in
which it is run:
for varname in case select until while ; do
varlist=`cat "$0" | grep "^[]*$varname " | se
On Thu, 25 Jan 2001 at 10:21am (-0800), Brad Doster wrote:
> 1) I have a variable with a list of variable names as its content, e.g.
> 'varlist=$var1 $var2 $var3'. I want to manipulate $varlist such that it
> ='var1 var2 var3', i.e get rid of the '$'s in front of each variable name.
> A 'sed' ex
On Thu, Jan 25, 2001 at 10:21:39AM -0800, Brad Doster wrote:
> 1) I have a variable with a list of variable names as its content, e.g.
> 'varlist=$var1 $var2 $var3'. I want to manipulate $varlist such that it
> ='var1 var2 var3', i.e get rid of the '$'s in front of each variable name.
> A 'sed' e
-BEGIN PGP SIGNED MESSAGE-
Matthew Melvin wrote:
>
>You can use $IFS to tell bash to split on just the line feeds instead of the
>spaces
>[mloe@riverbank (1) bashtest]$ IFS='
>> '
Brilliant, thank you -- this was driving me nuts. I finally figured
out that the reason this works:
LI
-BEGIN PGP SIGNED MESSAGE-
Mark -
You're right, that's an odd inconsistency. I thought perhaps we could
modify IFS, but it uses space/tab/newline by default, yet it doesn't
seem to be splitting on the space in the first example. (I would
think it should.) These two commands produce i
Use quotes.. these things ---> " "
:)
I didn't get to read your whole message, but quotes protect text from
default parameterization rules of the shell, etc.
Therefore: cat "Filename with spaces.txt"
will.. well.. you get the idea
A common script I do do is like:
for f in *.c
do
echo -e "$f"
Put double-quotes around your variables. :)
--
Todd A. Jacobs
Senior Network Consultant
___
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list
On Sat, 25 Nov 2000, Mark Ivey wrote:
> Here are two more scripts, similar to the first 2:
>LIST=*; for NAME in $LIST; do echo "-->" $NAME; done
>LIST=$(\ls); for NAME in $LIST; do echo "-->" $NAME; done
>
> They give different output. The first one gives:
>--> Astral Projection
On Thu, 27 Jan 2000, Jeff Smelser wrote:
> Just trying to write a bash script and can't seem to figure out how to
> do addition with variables. If someone could give me a quick example, I
> would appreciate it. Thanks
Here is a script with lots of math examples.
-- cut --
#!/bin/ksh
#
If no one minds, I'd just like to amplify on this a little. The solution
below uses the primitive Bourne shell method which uses an external
program (expr) to do the arithmetic. Bash has internal functionality to
perform stuff like this. The hashpling at the beginning specifies which
interpreter i
On Thu, 27 Jan 2000, Jeff Smelser wrote:
> this worked great, thanks a lot!
>
>
> On Thu, 27 Jan 2000, Bret Hughes wrote:
>
> > Try some thing like this
> >
> >
> > #! /bin/sh
> > # addnums - adds two numbers input as args and outputs the result
> > newval=`expr $1 + $2`
You can also use bc
#!/bin/sh
var1=5
var2=6
echo "$var1 + $var2" | bc
# end
Have fun,
--
Rick L. Mantooth
[EMAIL PROTECTED]
As I said before, I never repeat myself!
On Thu, 27 Jan 2000, Jeff Smelser wrote:
=> Just trying to write a bash script and can't seem to figure out how to
=> do additio
this worked great, thanks a lot!
On Thu, 27 Jan 2000, Bret Hughes wrote:
> Try some thing like this
>
>
> #! /bin/sh
> # addnums - adds two numbers input as args and outputs the result
> newval=`expr $1 + $2`
> echo 'the sum of ' $1 ' and ' $2 ' is ' $newval
>
>
> Jeff
Try some thing like this
#! /bin/sh
# addnums - adds two numbers input as args and outputs the result
newval=`expr $1 + $2`
echo 'the sum of ' $1 ' and ' $2 ' is ' $newval
Jeff Smelser wrote:
>
> Just trying to write a bash script and can't seem to figure out how to
> do addition with variab
61 matches
Mail list logo