[newbie] shell scripts

1999-09-11 Thread R. David Whitlock

OK, I figured out the aliases stuff on my own and made up a more elegant
solution, in case any one here wanted to try it.  And I'm always up for
suggestions:

The script /etc/bashrc _IS_ being executed, but just it, not the ~.bashrc
as far as I can tell.  My problem before was a stupid syntax error.

So I have the /etc/bashrc source the ~/.login script, a file I created to
hold any and all login to shell type stuff I want.  This file in turn
sources the .alias file in my directory.  So now, new adds go into
~/.alias, and any other at-login style directions can be included in
~/.login.  

Later,
 David

"Without the Law, there is no Liberty.  Without Justice, there is no Law."




Re: [newbie] shell scripts example how to find out dynamically assigned IP address?

1999-08-06 Thread Jo

Well, I'm trying to find out my dynamically assigned IP address. I got
this far:

ifconfig  ifc
grep --context=1 eth1 ifc  ifc1
grep "inet addr:" ifc1  ifc2 

Now I have to get the IP address from that line I isolated into a
variable.

Anybody?

Many thanks,

Jo


Axalon wrote:
 
 On Fri, 9 Jul 1999, Yants wrote:
 
  how do i write shell scripts..?
  can someone please show me an example...
 
 
 -=-=- useless bash script v1.0
 #!/bin/bash
 sleep 10
 -=-=-



Re: [newbie] shell scripts example how to find out dynamically assigned IP address?

1999-08-06 Thread Steve Philp

Jo wrote:
 
 Well, I'm trying to find out my dynamically assigned IP address. I got
 this far:
 
 ifconfig  ifc
 grep --context=1 eth1 ifc  ifc1
 grep "inet addr:" ifc1  ifc2
 
 Now I have to get the IP address from that line I isolated into a
 variable.

 Axalon wrote:
 
  On Fri, 9 Jul 1999, Yants wrote:
 
   how do i write shell scripts..?
   can someone please show me an example...
  
 
  -=-=- useless bash script v1.0
  #!/bin/bash
  sleep 10
  -=-=-

How 'bout this one-liner:

IFADDR=`/sbin/ifconfig eth1 | grep "inet addr:" | cut -f2 -d: | cut -f1
-d" "`

IFADDR gets the output of the command pipeline inside the `s.  Get the
output of /sbin/ifconfig for the specific interface, grab just the
address line, grab from the colon to the next colon, then trim off the
end of the IP address.

Anyone got anything shorter?? 
-- 
Steve Philp
Network Administrator
Advance Packaging Corporation
[EMAIL PROTECTED]



Re: [newbie] shell scripts example how to find out dynamically assigned IP address?

1999-08-06 Thread Jo

Great! Many thanks,

For anything shorter, I will need a lot more practice first...

Jo

Steve Philp wrote:
 
 Jo wrote:
 
  Well, I'm trying to find out my dynamically assigned IP address. I got
  this far:
 
  ifconfig  ifc
  grep --context=1 eth1 ifc  ifc1
  grep "inet addr:" ifc1  ifc2
 
  Now I have to get the IP address from that line I isolated into a
  variable.
 
  Axalon wrote:
  
   On Fri, 9 Jul 1999, Yants wrote:
  
how do i write shell scripts..?
can someone please show me an example...
   
  
   -=-=- useless bash script v1.0
   #!/bin/bash
   sleep 10
   -=-=-
 
 How 'bout this one-liner:
 
 IFADDR=`/sbin/ifconfig eth1 | grep "inet addr:" | cut -f2 -d: | cut -f1
 -d" "`
 
 IFADDR gets the output of the command pipeline inside the `s.  Get the
 output of /sbin/ifconfig for the specific interface, grab just the
 address line, grab from the colon to the next colon, then trim off the
 end of the IP address.
 
 Anyone got anything shorter??
 --
 Steve Philp
 Network Administrator
 Advance Packaging Corporation
 [EMAIL PROTECTED]



Re: [newbie] shell scripts

1999-07-10 Thread Kuraiken

Yants wrote:
 
 how do i write shell scripts..?
 can someone please show me an example...

You know what shell script is, right? Well, the question of how depends on the
shell you're using. pdksh, csh (c shell), bash all have slightly different
err...dialects.

Also, you can right "shell" scripts using perl or python.

Here's an example in python:

Argh...I cannot cut and paste from kedit to netscape messenger...rats...it's the
multiple file rename script I wrote a long time ago...it's simple enough to
understand.
If you're interested, please mail me. (don't want to flood the list with silly
hacks :-\)
-- 
-
Kuraiken - Python fanatic.
-
Python. Try it. It'll swallow you whole!
-



Re: [newbie] shell scripts

1999-07-10 Thread Michael R. Batchelor

At 10:34 PM 7/9/99 -0700, you wrote:
how do i write shell scripts..?
can someone please show me an example...

cd to /usr/bin

type "file *"

This will give a list of the file type for everything in the /usr/bin
directory, and many of them are really, really good professionally done
shell scripts of different types. Copy some of them to your home directory
and start hacking away. Look at the O'Rielly Nutshell books, too.

MB
--
Michael R. Batchelor
Industrial Informatics  Instrumentation, Inc.



Re: [newbie] shell scripts

1999-07-10 Thread Irv Mullins

On Mon, 08 May 2000, you wrote:
 On Fri, 9 Jul 1999, Yants wrote:
 
  how do i write shell scripts..?
  can someone please show me an example...
  
Here's an example from Richard Petersen's handy
Linux Programmer's Reference: (Good book to have around)

#!/bin/bash
#Program to allow the user to select different
#ways of listing files
 
echo s. List Sizes
echo l. List All file info
echo c. List C files
echo -n "Please enter choice: "
read choice
case $choice in
   s)
   ls -s
   ;;
l)
   ls -l
   ;;
c)
ls *.c
;;
   *)
  echo Invalid Option
esac
 
copy it, save it as, for example, lschoice, and chmod u+x so that you can
execute it by typing ./lschoice

HTH
Irv Mullins  



[newbie] shell scripts

1999-07-09 Thread Yants

how do i write shell scripts..?
can someone please show me an example...