Re: [newbie] invoking bash scripts

2001-04-16 Thread David E . Fox

On Saturday 14 April 2001 18:28, you wrote:
 I tried ./scriptname and bash reports "No such file or
 directory".  I can ls and it shows scriptname* which should
 indicate that it is executable and in the current directory.

Careful here. Scripts can be confused in the sense that it'll report
'no such file' when in reality it's not looking at your script (which
is there) but at the interpreter in the first line, and complaining
about that.

bash should (and usually is) invoked as '#! /bin/sh' so I'd try that
first. Even so, there should be a symlink in /bin that points 'bash' to 'sh' 
(or vice versa) so that '#! /bin/sh' or '#! /bin/bash' should produce 
equivalent behavior.

 cdrom.  Many of the commands fail (e.g. echo -n "Where do
 you work").

Funny, it prints that text even though I'm not working right now :(.

'echo' is a built in for bash, but there is also a command 'echo'. According
to the echo manpage, -n just doesn't give a trailing new line.


-- 

David E. Fox  Thanks for letting me
[EMAIL PROTECTED]change magnetic patterns
[EMAIL PROTECTED]   on your hard disk.
---




[Fwd: [newbie] invoking bash scripts]

2001-04-16 Thread Dean Steichen

"David E.Fox"
Here is the bash script I am having problems with...It was
copied from the cdrom for "Linux Shells by Example".  (The
lines between the strings of ..
are the script in question.)


#!/bin/bash
# Scriptname: nosy
echo -e "Are you happy? \c"
read answer
echo "$answer is the right response."
echo -e "What is your full name? \c"
read first middle last
echo "Hello  $first"

echo -n "Where do you work? "
read
echo I guess $REPLY keeps you busy!
#
read -p "Enter your job title: "
echo "I thought you might be an $REPLY."

echo -n "Who are your best friends? "
read -a friends
echo "Say hi to ${friends[2]}."
*
It is mostly the read command that does not work (e.g. the
line 4: read answer does not capture the answer and line 5:
echo "$answer" does not print the answer supplied.

I execute the script by issuing the following: bash nosy.

Here is the version of bash reported by bash - version

[deans@queen deans]$ bash -version GNU bash, version
2.04.12(1)-release (i586-mandrake-linux-gnu) Copyright 1999
Free Software Foundation, Inc. [deans@queen deans]$ 
  
Any ideas
-- 
Dean Steichen
Linux - Mandrake 7.1 
Netscape Mail
[EMAIL PROTECTED]


"David E.Fox"
Here is the bash script I am having problems with...It was
copied from the cdrom for "Linux Shells by Example".  (The
lines between the strings of ..
are the script in question.)


#!/bin/bash
# Scriptname: nosy
echo -e "Are you happy? \c"
read answer
echo "$answer is the right response."
echo -e "What is your full name? \c"
read first middle last
echo "Hello  $first"

echo -n "Where do you work? "
read
echo I guess $REPLY keeps you busy!
#
read -p "Enter your job title: "
echo "I thought you might be an $REPLY."

echo -n "Who are your best friends? "
read -a friends
echo "Say hi to ${friends[2]}."
*
It is mostly the read command that does not work (e.g. the
line 4: read answer does not capture the answer and line 5:
echo "$answer" does not print the answer supplied.

I execute the script by issuing the following: bash nosy.

Here is the version of bash reported by bash - version

[deans@queen deans]$ bash -version GNU bash, version
2.04.12(1)-release (i586-mandrake-linux-gnu) Copyright 1999
Free Software Foundation, Inc. [deans@queen deans]$ 
  
Any ideas
-- 
Dean Steichen
Linux - Mandrake 7.1 
Netscape Mail
[EMAIL PROTECTED]




[newbie] invoking bash scripts

2001-04-14 Thread Dean Steichen

Is there some option I need to set to invoke a bash script?

I have created a script with the #!/bin/bash as the first
line and have chmod +x scriptname to make it executable but
it will not execute unless I issue the "bash scriptname"
command (preceed the scriptname with the command bash).
Is this normal?

 -- 
Dean Steichen
Mandrake 7.1 K-Mail
[EMAIL PROTECTED]




Re: [newbie] invoking bash scripts

2001-04-14 Thread Keith Christian

Hi Dean,

Likely your system is set up (properly so) without the current
directory in the path.

To invoke a shell script named, say, foo.sh, type this:

./foo.sh (Notice the leading dot-slash) and it should run.  This
indicates that the script is in the current directory: dot represents
the current directory, slash is the pathname separator.

Keith


--- Dean Steichen [EMAIL PROTECTED] wrote:
 Is there some option I need to set to invoke a bash script?
 
 I have created a script with the #!/bin/bash as the first
 line and have chmod +x scriptname to make it executable but
 it will not execute unless I issue the "bash scriptname"
 command (preceed the scriptname with the command bash).
 Is this normal?
 
  -- 
 Dean Steichen
 Mandrake 7.1 K-Mail
 [EMAIL PROTECTED]
 


__
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/




Re: [newbie] invoking bash scripts

2001-04-14 Thread Dean Steichen

I tried ./scriptname and bash reports "No such file or
directory".  I can ls and it shows scriptname* which should
indicate that it is executable and in the current directory.
btw:
I bought the book "LINUX Shells by Example" by Ellie Quigley
and have been trying to run some of the scripts from the
cdrom.  Many of the commands fail (e.g. echo -n "Where do
you work").
Any other ideas?
Thanks in advance.
Dean
***


Keith Christian wrote:
 
 Hi Dean,
 
 Likely your system is set up (properly so) without the current
 directory in the path.
 
 To invoke a shell script named, say, foo.sh, type this:
 
 ./foo.sh (Notice the leading dot-slash) and it should run.  This
 indicates that the script is in the current directory: dot represents
 the current directory, slash is the pathname separator.
 
 Keith
 
 --- Dean Steichen [EMAIL PROTECTED] wrote:
  Is there some option I need to set to invoke a bash script?
 
  I have created a script with the #!/bin/bash as the first
  line and have chmod +x scriptname to make it executable but
  it will not execute unless I issue the "bash scriptname"
  command (preceed the scriptname with the command bash).
  Is this normal?
 
   --
  Dean Steichen
  Mandrake 7.1 K-Mail
  [EMAIL PROTECTED]
 
 
 __
 Do You Yahoo!?
 Get email at your own domain with Yahoo! Mail.
 http://personal.mail.yahoo.com/

-- 
Dean Steichen
Linux - Mandrake 7.1 
Netscape Mail
[EMAIL PROTECTED]