CD in Script

CD in Script

Post by Bruce Burhan » Fri, 02 Aug 2002 10:46:50



    Would someone please tell me why  this won't work-

#!/bin/sh
cd  /home/me

What I get on stderr is:

bash : scriptname :  cd :  no such file or directory

The permissions and ownership are the same as every
other script in my /usr/local/bin........

And it works fine from the commandline.....

Thanks......I'm about ready to pull my hair out!

Bruce<+>

 
 
 

CD in Script

Post by Bruce Burhan » Fri, 02 Aug 2002 11:06:16


Note corrections below. Sorry


Quote:

>     Would someone please tell me why  this won't work-

> #!/bin/sh
> cd  /home/me

> What I get on stderr is:

corrections  here-  [......]

Quote:> bash : scriptname :  cd : [ /home/me  : ] no such file or directory

[ makes no difference what path is in the script, nor
where it is run from....]
Quote:

> The permissions and ownership are the same as every
> other script in my /usr/local/bin........

> And it works fine from the commandline.....

> Thanks......I'm about ready to pull my hair out!

> Bruce<+>


 
 
 

CD in Script

Post by Dan » Fri, 02 Aug 2002 17:00:49



> Note corrections below. Sorry



> >     Would someone please tell me why  this won't work-

> > #!/bin/sh

My question is if it is executing bourne shell (#!/bin/sh) why are you
getting BASH errors?
 
 
 

CD in Script

Post by Ingo Blechschmid » Fri, 02 Aug 2002 19:16:56



> > >     Would someone please tell me why  this won't work-

> > > #!/bin/sh

> My question is if it is executing bourne shell (#!/bin/sh) why are you
> getting BASH errors?

Maybe because (at least on my Linux box) /bin/sh is a symlink to
/bin/bash.

HTH,

Ingo Blechschmidt

--
Linux, the choice          | I am a signature virus. Distribute me until
of a GNU generation   -o)  | the bitter end.  
Kernel 2.4.4          /\\  |
on a i686            _\\_v |
                           |

 
 
 

CD in Script

Post by S?ren Hanse » Fri, 02 Aug 2002 21:26:34



>> #!/bin/sh
>> cd  /home/me
>> bash : scriptname :  cd : [ /home/me  : ] no such file or directory

What does "ls -l /home/me" say?

--
S?ren Hansen                    Linuxkonsulent I/S
Open source specialist          http://www.linuxkonsulent.dk
My code (if any) in this post is copyright 2002, S?ren Hansen
and may be copied under the terms of the GNU General Public License

 
 
 

CD in Script

Post by Bruce Burhan » Fri, 02 Aug 2002 23:35:02





> > Note corrections below. Sorry



> > >     Would someone please tell me why  this won't work-

> > > #!/bin/sh

> My question is if it is executing bourne shell (#!/bin/sh) why are you
> getting BASH errors?

    In Debian/GNU  Linux,  /bin/sh is a link to /bin/bash.
Should have made that clear. Sorry.

Bruce<+>

 
 
 

CD in Script

Post by Bruce Burhan » Fri, 02 Aug 2002 23:58:09




> >> #!/bin/sh
> >> cd  /home/me

> >> bash : scriptname :  cd : [ /home/me  : ] no such file or directory

> What does "ls -l /home/me" say?

    drwx------ 16 me me 2048 aug 1 07:37 me

Soren,  I have tried the script  with many  directories in
it,  from many directories, with  and without the  #!.....
and with "exit" afterwords and without......Putting it in
braces or parens......Double quotes.......

ownership is me me  and permissions are rwxr-wr-w

The target directory is actually   $(cat  /home/me/.t2)
which changes according to the activity in another script,
but I  didn't  include that because I tried  it by plugging
the value directly with the same results.....

But when I run it from the commandline,  it works great,
from every directory......

Today, it works not at ALL! ! ! !  I just get another prompt.......

Thanks.....

Bruce<+>

Quote:> --
> S?ren Hansen                    Linuxkonsulent I/S
> Open source specialist          http://www.linuxkonsulent.dk
> My code (if any) in this post is copyright 2002, S?ren Hansen
> and may be copied under the terms of the GNU General Public License

 
 
 

CD in Script

Post by Bruce Burhan » Tue, 06 Aug 2002 04:52:07



Quote:

>     Would someone please tell me why  this won't work-

> #!/bin/sh
> cd  /home/me

> What I get on stderr is:

> bash : scriptname :  cd :  no such file or directory

> The permissions and ownership are the same as every
> other script in my /usr/local/bin........

> And it works fine from the commandline.....

> Thanks......I'm about ready to pull my hair out!

> Bruce<+>

    Well.  I've found out how to make it work=  just
source the file on invocation with a dot and a space
before the name.
    Whether the #!/bin/sh is there or not makes no difference.....
    Could anyone tell me how to include this is in the
script  itself?

Bruce<+>

 
 
 

CD in Script

Post by Rich » Wed, 07 Aug 2002 02:57:59





> >     Would someone please tell me why  this won't work-
> > #!/bin/sh
> > cd  /home/me
> > What I get on stderr is:
> > bash : scriptname :  cd :  no such file or directory
> > The permissions and ownership are the same as every
> > other script in my /usr/local/bin........
> > And it works fine from the commandline.....
> > Thanks......I'm about ready to pull my hair out!
> > Bruce<+>
>     Well.  I've found out how to make it work=  just
> source the file on invocation with a dot and a space
> before the name.
>     Whether the #!/bin/sh is there or not makes no difference.....
>     Could anyone tell me how to include this is in the
> script  itself?

I'm curious why you would want a script to get to your home
directory to begin with, "cd" with no arguments should take
you home.

If you need to change directories you cannot use a script to
do it anyway, it runs in it's own subshell and it will go
to that directory and exit, which will not affect your login
shell at all. To change directories you need to use an alias,
which runs in your shell.

Rich

- Show quoted text -

Quote:> Bruce<+>

 
 
 

CD in Script

Post by Bruce Burhan » Wed, 07 Aug 2002 11:49:35






> > >     Would someone please tell me why  this won't work-

> > > #!/bin/sh
> > > cd  /home/me

> > > What I get on stderr is:

> > > bash : scriptname :  cd :  no such file or directory

> > > The permissions and ownership are the same as every
> > > other script in my /usr/local/bin........

> > > And it works fine from the commandline.....

> > > Thanks......I'm about ready to pull my hair out!

> > > Bruce<+>

> >     Well.  I've found out how to make it work=  just
> > source the file on invocation with a dot and a space
> > before the name.
> >     Whether the #!/bin/sh is there or not makes no difference.....
> >     Could anyone tell me how to include this is in the
> > script  itself?

> I'm curious why you would want a script to get to your home
> directory to begin with, "cd" with no arguments should take
> you home.

> If you need to change directories you cannot use a script to
> do it anyway, it runs in it's own subshell and it will go
> to that directory and exit, which will not affect your login
> shell at all. To change directories you need to use an alias,
> which runs in your shell.

> Rich

> > Bruce<+>

Thanks Rich.

 The  actual cd is to a  directory  sent from another
script from a variable to a  temporary file where it cats
over the last entry....I just simplified it after discovering
that it was just the cd that wasn't working.....

 By "an  alias that runs in your shell"   you mean   that
I  _set_  the alias in the shell as in   "alias  HR=cd" ?

Bruce<+>

 
 
 

CD in Script

Post by those who know me have no need of my nam » Sun, 11 Aug 2002 14:46:21


in comp.unix.shell i read:


>> Maybe because (at least on my Linux box) /bin/sh is a symlink to
>> /bin/bash.

>It's always bugged me that bash doesn't allow bash-isms when called
>as sh .  It makes it hard to create scripts on e.g. Linux machines
>and then port them to machines where sh really is sh .

actually that's backwards.  (ah, i see that you caught that later.)  if you
want portability you have to work at it.  using zsh can help since it
provides a different subset and restrictions when invoked as sh.  ksh can
also help to remove the bash-ism's.  though you have to be careful not to
replace them with ksh-ism's or zsh-ism's -- which *can* be tempting.  maybe
develop your scripts on your lowest common platform, instead of the
platform you like to use -- hee.

--
bringing you boring signatures for 17 years

 
 
 

CD in Script

Post by Griff Miller I » Tue, 13 Aug 2002 23:11:04



> in comp.unix.shell i read:


>>>Maybe because (at least on my Linux box) /bin/sh is a symlink to
>>>/bin/bash.

>>It's always bugged me that bash doesn't allow bash-isms when called
>>as sh .  It makes it hard to create scripts on e.g. Linux machines
>>and then port them to machines where sh really is sh .

> actually that's backwards.  (ah, i see that you caught that later.)

Yes, I've got this *terrible* tendency to say the opposite of what I
mean. For example, I'll be giving someone directions, and say, "now
turn left on 5th Street and head south" and people will reply "wouldn't
a left turn point me north?" and the smack! sound of my palm striking
my forehead can be heard for miles around.

Obviously, it's starting to creep into my Usenet posts as well. Now I'm
really starting to get worried.  :)

Quote:> if you
> want portability you have to work at it.  using zsh can help since it
> provides a different subset and restrictions when invoked as sh.  ksh can
> also help to remove the bash-ism's.  though you have to be careful not to
> replace them with ksh-ism's or zsh-ism's -- which *can* be tempting.  maybe
> develop your scripts on your lowest common platform, instead of the
> platform you like to use -- hee.

All correct, and the lowest-common-platform technique (or rather, the
use-the-platform-where-sh-is-really-sh technique) is what I use when I
have to create a Bourne shell script that has to run on multiple platforms.
However, I also have to contend with what other people write, and now even
autoconfigure scripts are starting to get bash-ism's in them, since often
the package being autoconfigured started out on Linux. If bash would simply
really emulate sh when called as sh, this would tend to be less of a problem.

It's not a big deal, and I realize the author(s) of bash may well have had
better things to do when starting bash, but it would have been nice. Of
course, it's probably far too late to go changing it now.

When I get a "sh" script, e.g. in the form of an autoconfigure script or
install script from some software vendor who wrote it on a platform where
sh->bash, and have to run it on a system where sh is really sh, it's usually
easier to just change the first line of the script to #!/path/to/bash (which
may require installing bash). Funny, bash is sort of Microsoftian in that way;
its shortcomings further its necessity.  :)

--
Griff Miller II                   |                                           |
Manager of Information Technology | If you're too open-minded,                |
Positron Corporation              | your brains might fall out.               |

 
 
 

1. Script to eject CD-ROM drive and ask for appropriate CD??

I download lots of large movie files from P2P networks, which I place
on CD-Rs.  I then remove the movie files from my computer, and leave a
reference to the CD.  I would like to create a script that will do the
following when I click on it / execute it:

(1) Eject te CD-ROM drive

(2) Ask me to "Insert the appropriate CD-ROM (i.e., Please insert CD
labelled "FINAL DESTINATION") then press any key"

(3) Wait to proceed until I press a button

(4) If the CD-ROM drive is out, retract it

(5) Check the MD5SUM of the movie file on the CD-R and compare it to
the known MD5SUM of the movie file (which I would have determined
before making the CD) and then play the CD using the appropriate
program (i.e., a DivX player).  Alternatively, if the improper CD was
inserted, it would return to step (1).

2. Need HELP with radiuis on Freebsd

3. Execute a sh script under perl and sh: sh script; perl script?

4. Static libs and templates in tempinc

5. In search of Solaris 2.5 Netscape Navigator 3.0 plug ins

6. does not resolve subdomains

7. Need HELP to Log User Log-ins form the internet

8. Label editor is snake oil!

9. Suse 7.0; Yast2, kinternet, rc.dialout und ich komme nicht ins Internet

10. Netscape plug-ins on AIX 4

11. what is a INS server?

12. dial ins

13. plug-ins netscape