TechTalkz.com Logo

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Linux & Opensource > Mandriva Linux

Notices

Bash script error

Mandriva Linux


Reply
 
Thread Tools Display Modes
Old 09-01-2008, 05:46 AM   #11
David W. Hodgins
Guest
 
Posts: n/a
Re: Bash script error

On Mon, 07 Jan 2008 12:47:24 -0500, Bit Twister <BitTwister@mouse-potato.com> wrote:

> On Mon, 07 Jan 2008 12:38:26 -0500, David W. Hodgins wrote:
>> On Mon, 07 Jan 2008 11:54:12 -0500,
>> Bit Twister <BitTwister@mouse-potato.com> wrote:

>
>>> set - # set debugging mode off

>> Lol. Care to try again ...

>
> Nope. :-D


My bad. I should have checked the man page ...

`-'
Signal the end of options, cause all remaining ARGUMENTS to
be assigned to the positional parameters. The `-x' and `-v'
options are turned off. If there are no arguments, the
positional parameters remain unchanged.

I've always used set +x +v to turn off debugging. Didn't realize "set -",
without the +x +v would turn them off.

Learn something new everyday

Regards, Dave Hodgins

--
Change nomail.afraid.org to ody.ca to reply by email.
(nomail.afraid.org has been set up specifically for
use in usenet. Feel free to use it yourself.)
  Reply With Quote
Old 09-01-2008, 05:47 AM   #12
Jim Whitby
Guest
 
Posts: n/a
Re: Bash script error

On Tue, 08 Jan 2008 00:22:56 +1100, Doug Laidlaw wrote:

> if [ "$fullpath" = "" ]; then
> fullpath="$1"
> fi
> # Is the awk/ls magic portable?
> if [ -L "$fullpath" ]; then
> fullpath="`ls -l "$fullpath" | awk '{print $11}'`"
> fi
> dirname $fullpath


Was fullpath exported? Is this run in a shell?

running fullpath=/etc/udev;export fullpath;foo.sh produces:

/etc

running fullpath="";export fullpath;foo.sh `pwd` produces:

/home


  Reply With Quote
Old 09-01-2008, 05:47 AM   #13
Bit Twister
Guest
 
Posts: n/a
Re: Bash script error

On Mon, 07 Jan 2008 12:38:26 -0500, David W. Hodgins wrote:
> On Mon, 07 Jan 2008 11:54:12 -0500,
> Bit Twister <> wrote:


>> set - # set debugging mode off

>
> Lol. Care to try again ...


Nope. :-D

> set +x # set debugging mode off


Well, that does work. Just a habit for me to use "set -" since I might
have used set -xv

or any other switches.
  Reply With Quote
Old 09-01-2008, 05:47 AM   #14
Peter D.
Guest
 
Posts: n/a
Re: Bash script error

on Tuesday 08 January 2008 00:22
in the Usenet newsgroup alt.os.linux.mandriva
Doug Laidlaw wrote:

> This is from the Creatures Docking Station, which is really too old to
> use.
>
> But for my own knowledge, the bit below gives an error that 'dirname' is
> missing an operand;
>
> if [ "$fullpath" = "" ]; then
> fullpath="$1"
> fi
> # Is the awk/ls magic portable?
> if [ -L "$fullpath" ]; then
> fullpath="`ls -l "$fullpath" | awk '{print $11}'`"
> fi
> dirname $fullpath
>
> Setting a variable like this is common. Why doesn't it work in this
> instance? It should ultimately resolve to "dirname $1" or whatever
> fullpath is ultimately set at?
>
> TIA,
>
> Doug.


Try running "bash -euxv <script name>" for some more information.


--
sig goes here...
Peter D.
  Reply With Quote
Old 09-01-2008, 05:47 AM   #15
Jim Whitby
Guest
 
Posts: n/a
Re: Bash script error

On Tue, 08 Jan 2008 00:22:56 +1100, Doug Laidlaw wrote:

> if [ "$fullpath" = "" ]; then
> fullpath="$1"
> fi
> # Is the awk/ls magic portable?
> if [ -L "$fullpath" ]; then
> fullpath="`ls -l "$fullpath" | awk '{print $11}'`"
> fi
> dirname $fullpath


Was fullpath exported? Is this run in a shell?

running fullpath=/etc/udev;export fullpath;foo.sh produces:

/etc

running fullpath="";export fullpath;foo.sh `pwd` produces:

/home


  Reply With Quote
Old 09-01-2008, 05:47 AM   #16
Jim Whitby
Guest
 
Posts: n/a
Re: Bash script error

On Tue, 08 Jan 2008 00:22:56 +1100, Doug Laidlaw wrote:

> This is from the Creatures Docking Station, which is really too old to
> use.
>
> But for my own knowledge, the bit below gives an error that 'dirname' is
> missing an operand;
>
> if [ "$fullpath" = "" ]; then
> fullpath="$1"
> fi
> # Is the awk/ls magic portable?
> if [ -L "$fullpath" ]; then
> fullpath="`ls -l "$fullpath" | awk '{print $11}'`"
> fi
> dirname $fullpath
>
> Setting a variable like this is common. Why doesn't it work in this
> instance? It should ultimately resolve to "dirname $1" or whatever
> fullpath is ultimately set at?
>
> TIA,
>
> Doug.


If the dirname is a link. Try changing 11 to 10 in the awk statement.
  Reply With Quote
Old 09-01-2008, 05:47 AM   #17
Jim Whitby
Guest
 
Posts: n/a
Re: Bash script error

On Mon, 07 Jan 2008 22:53:24 +0000, Bit Twister wrote:

> On Mon, 07 Jan 2008 16:33:18 -0600, Jim Whitby wrote:
>
>> If the dirname is a link. Try changing 11 to 10 in the awk statement.

>
> and back to 11 if not.


Hmmmm...

I just did a quick check. It would appear the awk statement is not
portable.

In order for it to work here. The real dir is field 10, the link is field
8.

eg.

lrwxrwxrwx 1 jim jim 13 2007-11-30 21:55 /home/jim/vuse -> /public2/vuse/
__________ _ ___ ___ __ __________ _____ ______________ __ ______________
1 2 3 4 5 6 7 8 9 10

Given that it appears yours and Doug's is 11, it can't be portable.



  Reply With Quote
Old 09-01-2008, 05:47 AM   #18
Jim Whitby
Guest
 
Posts: n/a
Re: Bash script error

On Tue, 08 Jan 2008 00:22:56 +1100, Doug Laidlaw wrote:

> This is from the Creatures Docking Station, which is really too old to
> use.
>
> But for my own knowledge, the bit below gives an error that 'dirname' is
> missing an operand;
>
> if [ "$fullpath" = "" ]; then
> fullpath="$1"
> fi
> # Is the awk/ls magic portable?
> if [ -L "$fullpath" ]; then
> fullpath="`ls -l "$fullpath" | awk '{print $11}'`"
> fi
> dirname $fullpath
>
> Setting a variable like this is common. Why doesn't it work in this
> instance? It should ultimately resolve to "dirname $1" or whatever
> fullpath is ultimately set at?
>
> TIA,
>
> Doug.


If the dirname is a link. Try changing 11 to 10 in the awk statement.
  Reply With Quote
Old 09-01-2008, 05:47 AM   #19
Bit Twister
Guest
 
Posts: n/a
Re: Bash script error

On Mon, 07 Jan 2008 16:33:18 -0600, Jim Whitby wrote:

> If the dirname is a link. Try changing 11 to 10 in the awk statement.


and back to 11 if not.
  Reply With Quote
Old 09-01-2008, 05:48 AM   #20
Bit Twister
Guest
 
Posts: n/a
Re: Bash script error

On Mon, 07 Jan 2008 20:33:36 -0600, Jim Whitby wrote:
>
> eg.
>
> lrwxrwxrwx 1 jim jim 13 2007-11-30 21:55 /home/jim/vuse -> /public2/vuse/
> __________ _ ___ ___ __ __________ _____ ______________ __ ______________
> 1 2 3 4 5 6 7 8 9 10
>
> Given that it appears yours and Doug's is 11, it can't be portable.


I was giving you a hard time.
I was hinting the file may or may not be a link.

11 not valid here either.

My ls -al is same as yours.
lrwxrwxrwx 1 root root 20 2007-11-19 15:55 shut_down_init -> /local/shut_down
__________ _ ___ ___ __ __________ _____ ______________ __ ______________
1 2 3 4 5 6 7 8 9 10
  Reply With Quote
Reply

Thread Tools
Display Modes



< Windows Help - MS Office Help - Hardware Support >


New To Site? Need Help?

All times are GMT +5.5. The time now is 05:15 AM.


vBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2009, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional