Script does not do what it is told to do

2019-10-24 Thread Ken Heard
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Whenever I run this script -- or several others like it

#!/bin/bash
# Script to back up all browser files in directory /home/ken/mozilla.
STARTDIR=$PWD
cd /home/ken
tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
- --wildcards -T docs/tarlists/kbrowsers.lst
cd "$STARTDIR"

it returns the following:

ken@Turing:~$ tarkbrowsers
tar (child): /media/ssda/backups/kbrowsers.tgz: Cannot open: No such
file or directory
tar (child): Error is not recoverable: exiting now
tar: /media/ssda/backups/kbrowsers.tgz: Cannot write: Broken pipe
tar: Child returned status 2
tar: Error is not recoverable: exiting now

It is trying to save the tarball to a different portable storage
device, ssda, which had failed and consequently is no longer in
/etc/fstab.  How could such a thing happen?

However, if I pull the line with the tar command out of the script and
running it independently it does what it is told.  If there is
something wrong with the script I can't find it.

I also tried the script with the second line reading STARTDIR="$PWD";
but that change made no difference, the result was the same.

Help please!

Regards, Ken


-BEGIN PGP SIGNATURE-

iF0EARECAB0WIQR9YFyM2lJAhDprmoOU2UnM6QmZNwUCXbInjgAKCRCU2UnM6QmZ
N4QyAJkBqb+i4+4VRA38OWfWHV1GE15AmQCffAk/LjD8QAk48ElZPDk2ReI5RJc=
=tfcB
-END PGP SIGNATURE-



Re: Script does not do what it is told to do

2019-10-24 Thread Anuradha Weeraman
On Thu, Oct 24, 2019 at 06:37:08PM -0400, Ken Heard wrote:
> tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
> - --wildcards -T docs/tarlists/kbrowsers.lst

Try removing the single '-' at the beginning of the second line...

-- 
Regards
Anuradha



Re: Script does not do what it is told to do

2019-10-24 Thread deloptes
Ken Heard wrote:

> Whenever I run this script -- or several others like it
> 
> #!/bin/bash
> # Script to back up all browser files in directory /home/ken/mozilla.
> STARTDIR=$PWD
> cd /home/ken
> tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
> --wildcards -T docs/tarlists/kbrowsers.lst
> cd "$STARTDIR"
> 
> it returns the following:
> 

this is not possible because in the script you tell tar to create archive
in /media/fde/backups/

> ken@Turing:~$ tarkbrowsers
> tar (child): /media/ssda/backups/kbrowsers.tgz: Cannot open: No such
> file or directory
> tar (child): Error is not recoverable: exiting now
> tar: /media/ssda/backups/kbrowsers.tgz: Cannot write: Broken pipe
> tar: Child returned status 2
> tar: Error is not recoverable: exiting now
> 

and here you are failing to write /media/ssda/backups/kbrowsers.tgz

> It is trying to save the tarball to a different portable storage
> device, ssda, which had failed and consequently is no longer in
> /etc/fstab.  How could such a thing happen?
> 

obviously it is another script or whatever

> However, if I pull the line with the tar command out of the script and
> running it independently it does what it is told.  If there is
> something wrong with the script I can't find it.
> 
> I also tried the script with the second line reading STARTDIR="$PWD";
> but that change made no difference, the result was the same.
> 

The question is where do you want to write the data - if on media attached
then create entry in /etc/fstab so that you can mount it in consistent way,
change the script and the problem will be gone.

I have seen all kind of stupid and ugly admin scripts, where the author
himself does not know how or why it is or it is not working at the end.

regards




Re: Script does not do what it is told to do

2019-10-24 Thread Ken Heard
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 2019-10-24 7:12 p.m., Anuradha Weeraman wrote:

> On Thu, Oct 24, 2019 at 06:37:08PM -0400, Ken Heard wrote:
>> tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \ -
>> --wildcards -T docs/tarlists/kbrowsers.lst
> 
> Try removing the single '-' at the beginning of the second line...

In this instance it does not matter whether that '-' is there or not.
 Pulling that line out of the script and running it independently
works both with and without it.

Regards, Ken



-BEGIN PGP SIGNATURE-

iF0EARECAB0WIQR9YFyM2lJAhDprmoOU2UnM6QmZNwUCXbJHlQAKCRCU2UnM6QmZ
N9CyAJ0V2UNi7X6qEj+oTe24JWYyksnm/gCff2SSNSfy8oFTt6wS9R+8f5HupZY=
=nMke
-END PGP SIGNATURE-



Re: Script does not do what it is told to do

2019-10-24 Thread deloptes
Ken Heard wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> On 2019-10-24 7:12 p.m., Anuradha Weeraman wrote:
> 
>> On Thu, Oct 24, 2019 at 06:37:08PM -0400, Ken Heard wrote:
>>> tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \ -
>>> --wildcards -T docs/tarlists/kbrowsers.lst
>> 
>> Try removing the single '-' at the beginning of the second line...
> 
> In this instance it does not matter whether that '-' is there or not.
>  Pulling that line out of the script and running it independently
> works both with and without it.
> 


In the original post I did not see any dash screenshot attached





Re: Script does not do what it is told to do

2019-10-24 Thread Ken Heard
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 2019-10-24 8:40 p.m., deloptes wrote:
> Ken Heard wrote:
> 
>> Whenever I run this script -- or several others like it
>> 
>> #!/bin/bash # Script to back up all browser files in directory
>> /home/ken/mozilla. STARTDIR=$PWD cd /home/ken tar -czf
>> /media/fde/backups/kbrowsers.tgz  --exclude-caches \ --wildcards
>> -T docs/tarlists/kbrowsers.lst cd "$STARTDIR"
>> 
>> it returns the following:
>> 
> 
> this is not possible because in the script you tell tar to create
> archive in /media/fde/backups/

Yes, that is the location where I want the archive kbrowsers.tgz to be
put.

>> ken@Turing:~$ tarkbrowsers tar (child):
>> /media/ssda/backups/kbrowsers.tgz: Cannot open: No such file or
>> directory tar (child): Error is not recoverable: exiting now tar:
>> /media/ssda/backups/kbrowsers.tgz: Cannot write: Broken pipe tar:
>> Child returned status 2 tar: Error is not recoverable: exiting
>> now
>> 
> 
> and here you are failing to write
> /media/ssda/backups/kbrowsers.tgz

/media/ssda/ .. does not exist, neither as a directory or in /etc/fstab

>> It is trying to save the tarball to a different portable storage 
>> device, ssda, which had failed and consequently is no longer in 
>> /etc/fstab.  How could such a thing happen?
>> 
> 
> obviously it is another script or whatever

But how?

>> However, if I pull the line with the tar command out of the
>> script and running it independently it does what it is told.  If
>> there is something wrong with the script I can't find it.
>> 
>> I also tried the script with the second line reading
>> STARTDIR="$PWD"; but that change made no difference, the result
>> was the same.
>> 
> 
> The question is where do you want to write the data - if on media
> attached then create entry in /etc/fstab so that you can mount it
> in consistent way, change the script and the problem will be gone.

/media/fde is the mount point for the device to which will be written
the archive.  It is properly mounted, and I can write files to it and
read those files.  As I said in my original post I am able to write
the archive successfully to /media/fde/backups/ by copying the tar
command line to a console and read the contents of the tarball.

> I have seen all kind of stupid and ugly admin scripts, where the
> author himself does not know how or why it is or it is not working
> at the end.
> 
> regards

Regards, Ken



-BEGIN PGP SIGNATURE-

iF0EARECAB0WIQR9YFyM2lJAhDprmoOU2UnM6QmZNwUCXbJjwQAKCRCU2UnM6QmZ
NzIJAJ9Ng8JazKDR52yEBcyEoatQBu7PQACcCT5xNctrkAiobqpPGG1Soj9lmCI=
=fv+M
-END PGP SIGNATURE-



Re: Script does not do what it is told to do

2019-10-24 Thread The Wanderer
On 2019-10-24 at 18:37, Ken Heard wrote:

> Whenever I run this script -- or several others like it



> it returns the following:
> 
> ken@Turing:~$ tarkbrowsers
> tar (child): /media/ssda/backups/kbrowsers.tgz: Cannot open: No such
> file or directory

How are you invoking the script?

What does

$ type tarkbrowsers

report?

Does running the script with its full path, rather than by the bare
name, make any difference?

I'm wondering whether there might somehow be another script with this
same name, which is in your PATH ahead (and therefore getting invoked
instead) of the one you quoted for us.

No idea how that might have gotten to be the case, if so, but it's at
least worth explicitly ruling out.

-- 
   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man. -- George Bernard Shaw



signature.asc
Description: OpenPGP digital signature


Re: Script does not do what it is told to do

2019-10-25 Thread tomas
On Fri, Oct 25, 2019 at 02:40:00AM +0200, deloptes wrote:
> Ken Heard wrote:
> 
> > Whenever I run this script -- or several others like it
> > 
> > #!/bin/bash
> > # Script to back up all browser files in directory /home/ken/mozilla.
> > STARTDIR=$PWD
> > cd /home/ken
> > tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
> > --wildcards -T docs/tarlists/kbrowsers.lst
> > cd "$STARTDIR"
> > 
> > it returns the following:
> > 
> 
> this is not possible because in the script you tell tar to create archive
> in /media/fde/backups/

Possibly /media/fde is a (broken) symbolic link to /media/ssda?

Besides (but this probably hasn't to do with your failure):
what are you trying to achieve with 'STARTDIR=$PWD' and then
'cd "$STARTDIR"'?

Cheers
-- tomás


signature.asc
Description: Digital signature


Re: Script does not do what it is told to do

2019-10-25 Thread deloptes
Ken Heard wrote:

> the archive.  It is properly mounted, and I can write files to it and
> read those files.  As I said in my original post I am able to write
> the archive successfully to /media/fde/backups/ by copying the tar
> command line to a console and read the contents of the tarball.
> 

now there is difference 
- /media/fde/
+ /media/ssda/

In the script portion you pasted it is not visible that the disk is
dynamically set

tar -czf /media/fde/backups/kbrowsers.tgz 

How does it comes that you have different in the script and in the output


I recall that in debian since some time the mount changed from

/media/

to 

/media//





Re: Script does not do what it is told to do

2019-10-25 Thread Michael Howard

On 24/10/2019 23:37, Ken Heard wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Whenever I run this script -- or several others like it

#!/bin/bash
# Script to back up all browser files in directory /home/ken/mozilla.
STARTDIR=$PWD
cd /home/ken
tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
- --wildcards -T docs/tarlists/kbrowsers.lst
cd "$STARTDIR"

it returns the following:

ken@Turing:~$ tarkbrowsers
tar (child): /media/ssda/backups/kbrowsers.tgz: Cannot open: No such
file or directory
tar (child): Error is not recoverable: exiting now
tar: /media/ssda/backups/kbrowsers.tgz: Cannot write: Broken pipe
tar: Child returned status 2
tar: Error is not recoverable: exiting now

It is trying to save the tarball to a different portable storage
device, ssda, which had failed and consequently is no longer in
/etc/fstab.  How could such a thing happen?


There is nothing inherently wrong with the script, in that it would work 
if all other things were equal, but they are clearly not.


Do an 'ls -l' on '/media/fde/backups', does it reveal anything? It might 
well do.


Using the -C option to tar is preferable to the way you are doing it.  So,

tar -czf /media/fde/backups/kbrowsers.tgz --exclude-caches --wildcards -C 
/home/ken
 -T ./docs/tarlists/kbrowsers.lst

might be better. You  will return to your starting location then, 
without the need for STARTDIR gubbings.


Mike.

--




Re: Script does not do what it is told to do

2019-10-25 Thread john doe
On 10/25/2019 9:16 AM, to...@tuxteam.de wrote:
> On Fri, Oct 25, 2019 at 02:40:00AM +0200, deloptes wrote:
>> Ken Heard wrote:
>>
>>> Whenever I run this script -- or several others like it
>>>
>>> #!/bin/bash
>>> # Script to back up all browser files in directory /home/ken/mozilla.
>>> STARTDIR=$PWD
>>> cd /home/ken
>>> tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
>>> --wildcards -T docs/tarlists/kbrowsers.lst
>>> cd "$STARTDIR"
>>>
>>> it returns the following:
>>>
>>
>> this is not possible because in the script you tell tar to create archive
>> in /media/fde/backups/
>
> Possibly /media/fde is a (broken) symbolic link to /media/ssda?
>
> Besides (but this probably hasn't to do with your failure):
> what are you trying to achieve with 'STARTDIR=$PWD' and then
> 'cd "$STARTDIR"'?
>

Given that you are using bash, my guess is that the below should do what
you want:

STARTDIR=$(dirname $_)
cd $STARTDIR || exit $?

--
John Doe



Re: Script does not do what it is told to do

2019-10-25 Thread tomas
On Fri, Oct 25, 2019 at 09:33:51AM +0200, john doe wrote:
> On 10/25/2019 9:16 AM, to...@tuxteam.de wrote:
> > On Fri, Oct 25, 2019 at 02:40:00AM +0200, deloptes wrote:
> >> Ken Heard wrote:
> >>
> >>> Whenever I run this script -- or several others like it
> >>>
> >>> #!/bin/bash
> >>> # Script to back up all browser files in directory /home/ken/mozilla.
> >>> STARTDIR=$PWD
> >>> cd /home/ken
> >>> tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
> >>> --wildcards -T docs/tarlists/kbrowsers.lst
> >>> cd "$STARTDIR"
> >>>
> >>> it returns the following:
> >>>
> >>
> >> this is not possible because in the script you tell tar to create archive
> >> in /media/fde/backups/
> >
> > Possibly /media/fde is a (broken) symbolic link to /media/ssda?
> >
> > Besides (but this probably hasn't to do with your failure):
> > what are you trying to achieve with 'STARTDIR=$PWD' and then
> > 'cd "$STARTDIR"'?
> >
> 
> Given that you are using bash, my guess is that the below should do what
> you want:
> 
> STARTDIR=$(dirname $_)
> cd $STARTDIR || exit $?

My point is that all of this is unnecessary. For one, tar doesn't
change the current working directory all by itself. For two, if
all of that is run as a subshell, whatever change wouldn't propagate
"upstream".

Occam's razor.

Cheers
-- t


signature.asc
Description: Digital signature


Re: Script does not do what it is told to do

2019-10-25 Thread Greg Wooledge
On Fri, Oct 25, 2019 at 08:33:09AM +0100, Michael Howard wrote:
> On 24/10/2019 23:37, Ken Heard wrote:
> > #!/bin/bash
> > # Script to back up all browser files in directory /home/ken/mozilla.
> > STARTDIR=$PWD
> > cd /home/ken
> > tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
> > - --wildcards -T docs/tarlists/kbrowsers.lst
> > cd "$STARTDIR"

> There is nothing inherently wrong with the script,

Untrue.  I pointed out the flaws last time this subject was discussed
on this mailing list.  Was that just a few days ago, or was it last
week?  I don't remember.

> in that it would work if
> all other things were equal, but they are clearly not.

Lots of scripts will work "if certain conditions hold true".  That's the
fundamental problem here.  The script shown here is incredibly fragile,
and the author did not correct the flaws that I already pointed out
last time.  It may "work" under certain conditions.  How likely those
conditions are to be true, I have no way to know.

> Using the -C option to tar is preferable to the way you are doing it.

Yup, that was one of the three(?) proposals I made last time around,
none of which were followed.  *shrug*  Not much more I can do when
nobody listens to me.



Re: Script does not do what it is told to do

2019-10-25 Thread Michael Howard

On 25/10/2019 14:11, Greg Wooledge wrote:

On Fri, Oct 25, 2019 at 08:33:09AM +0100, Michael Howard wrote:

On 24/10/2019 23:37, Ken Heard wrote:

#!/bin/bash
# Script to back up all browser files in directory /home/ken/mozilla.
STARTDIR=$PWD
cd /home/ken
tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
- --wildcards -T docs/tarlists/kbrowsers.lst
cd "$STARTDIR"

There is nothing inherently wrong with the script,

Untrue.  I pointed out the flaws last time this subject was discussed
on this mailing list.  Was that just a few days ago, or was it last
week?  I don't remember.



Sorry, but it _is_ true. One can't know, nor should one, if the 
variables and paths are correct, but if they are, i.e. all things being 
equal, the script  is inherrently correct. Of course, it certainly isn't 
optimal.




in that it would work if
all other things were equal, but they are clearly not.

Lots of scripts will work "if certain conditions hold true".



See above.



That's the
fundamental problem here.  The script shown here is incredibly fragile,
and the author did not correct the flaws that I already pointed out
last time.  It may "work" under certain conditions.  How likely those
conditions are to be true, I have no way to know.



I have no idea about when or where the OP may have posted previously.



Using the -C option to tar is preferable to the way you are doing it.

Yup, that was one of the three(?) proposals I made last time around,
none of which were followed.  *shrug*  Not much more I can do when
nobody listens to me.



With your attitude, little wonder nobody listens to you. You're probably 
on the ignore list :)


Mike.

--




Re: Script does not do what it is told to do

2019-10-25 Thread Greg Wooledge
On Fri, Oct 25, 2019 at 02:28:02PM +0100, Michael Howard wrote:
> On 25/10/2019 14:11, Greg Wooledge wrote:
> > On Fri, Oct 25, 2019 at 08:33:09AM +0100, Michael Howard wrote:
> > > On 24/10/2019 23:37, Ken Heard wrote:
> > > > #!/bin/bash
> > > > # Script to back up all browser files in directory /home/ken/mozilla.
> > > > STARTDIR=$PWD
> > > > cd /home/ken
> > > > tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
> > > > - --wildcards -T docs/tarlists/kbrowsers.lst
> > > > cd "$STARTDIR"
> > > There is nothing inherently wrong with the script,
> > Untrue.  I pointed out the flaws last time this subject was discussed
> > on this mailing list.  Was that just a few days ago, or was it last
> > week?  I don't remember.
> 
> Sorry, but it _is_ true. One can't know, nor should one, if the variables
> and paths are correct, but if they are, i.e. all things being equal, the
> script  is inherrently correct. Of course, it certainly isn't optimal.

https://lists.debian.org/debian-user/2019/10/msg00768.html



Re: Script does not do what it is told to do

2019-10-25 Thread Thomas Schmitt
Hi,

Ken Heard wrote:
> Whenever I run this script -- or several others like it
> [...]
> tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
> - --wildcards -T docs/tarlists/kbrowsers.lst
> [...]
> it returns the following:
> [...]
> tar (child): /media/ssda/backups/kbrowsers.tgz: Cannot open: No such
> file or directory
> tar (child): Error is not recoverable: exiting now
> tar: /media/ssda/backups/kbrowsers.tgz: Cannot write: Broken pipe
> [...]
> However, if I pull the line with the tar command out of the script and
> running it independently it does what it is told.  If there is
> something wrong with the script I can't find it.

The only plausible theories i read so far are:
A: The script you run is not the script from which you take the tar
   command line.
B: tar gets somehow convinced that /media/fde/backups/kbrowsers.tgz
   is actually meant as /media/ssda/backups/kbrowsers.tgz.

(This is independent of the flaws of the script, which where pointed out.)

So i would try to exclude cause A by adding message output to the script,
and cause B by looking at the components of the .tgz path.
I.e. i would insert

  echo "Yes. This is indeed the script."
  ls -ld /media
  ls -ld /media/fde
  ls -ld /media/fde/backups
  ls -ld /media/fde/backups/kbrowsers.tgz

before

  tar -czf /media/fde/backups/kbrowsers.tgz   --exclude-caches \

Then i'd run the script and be curious what happens.


Have a nice day :)

Thomas



Re: Script does not do what it is told to do

2019-10-25 Thread David Wright
On Fri 25 Oct 2019 at 03:45:45 (+0200), deloptes wrote:
> Ken Heard wrote:
> 
> > -BEGIN PGP SIGNED MESSAGE-
> > Hash: SHA1
> > 
> > On 2019-10-24 7:12 p.m., Anuradha Weeraman wrote:
> > 
> >> On Thu, Oct 24, 2019 at 06:37:08PM -0400, Ken Heard wrote:
> >>> tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \ -
> >>> --wildcards -T docs/tarlists/kbrowsers.lst
> >> 
> >> Try removing the single '-' at the beginning of the second line...
> > 
> > In this instance it does not matter whether that '-' is there or not.
> >  Pulling that line out of the script and running it independently
> > works both with and without it.
> > 
> 
> 
> In the original post I did not see any dash screenshot attached

- And would you blame that on Knode or gmane (I use neither)?

It's also noticeable that the said hyphen, which was at the beginning
of the line in the OP and was quoted as such in the first reply, had
migrated to the end of the line in the OP's reply. That's not
exactly helpful when discussing anything to do with tar, notorious
for problems caused by its commandline syntax.

Does any of the odd punctuation \
- in this post - get affected similarly when
lines are kept short?

Re the OP, there's a lot of information we aren't a party to;
for example, what are /media/fde and /media/ssda - we've only
been told what one of them isn't. It also wouldn't be difficult
to put set -x into the script, which would show what's being
executed as well as confirming that the correct script is
being run (because there are "several others like it") by
tarkbrowsers.

Cheers,
David.



Re: Script does not do what it is told to do

2019-10-25 Thread David Wright
On Fri 25 Oct 2019 at 14:28:02 (+0100), Michael Howard wrote:
> On 25/10/2019 14:11, Greg Wooledge wrote:
> > On Fri, Oct 25, 2019 at 08:33:09AM +0100, Michael Howard wrote:
> > > On 24/10/2019 23:37, Ken Heard wrote:
> > > > #!/bin/bash
> > > > # Script to back up all browser files in directory /home/ken/mozilla.
> > > > STARTDIR=$PWD
> > > > cd /home/ken
> > > > tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
> > > > - --wildcards -T docs/tarlists/kbrowsers.lst
> > > > cd "$STARTDIR"
> > > There is nothing inherently wrong with the script,
> > Untrue.  I pointed out the flaws last time this subject was discussed
> > on this mailing list.  Was that just a few days ago, or was it last
> > week?  I don't remember.
> 
> Sorry, but it _is_ true. One can't know, nor should one, if the
> variables and paths are correct, but if they are, i.e. all things
> being equal, the script  is inherrently correct. Of course, it
> certainly isn't optimal.

What's the role of the hyphen between the two --switches, please.

> > > in that it would work if
> > > all other things were equal, but they are clearly not.
> > Lots of scripts will work "if certain conditions hold true".
> 
> See above.

If one "shouldn't know" about such conditions, then it seems pointless
to post this sort of problem on the list. One is better employed in
checking one's own assumptions, as Thomas has shown elsewhere in the
thread.

> > That's the
> > fundamental problem here.  The script shown here is incredibly fragile,
> > and the author did not correct the flaws that I already pointed out
> > last time.  It may "work" under certain conditions.  How likely those
> > conditions are to be true, I have no way to know.
> 
> I have no idea about when or where the OP may have posted previously.

Four days ago, on this list. Looking back to check the date, I see
that the said hyphen had a different, but equally mysterious, role
in the OP's script back there. Perhaps you could explain that hyphen
at the same time.

https://lists.debian.org/debian-user/2019/10/msg00758.html

> > > Using the -C option to tar is preferable to the way you are doing it.
> > Yup, that was one of the three(?) proposals I made last time around,
> > none of which were followed.  *shrug*  Not much more I can do when
> > nobody listens to me.
> 
> With your attitude, little wonder nobody listens to you. You're
> probably on the ignore list :)

That might explain some of the scripts seen here. I find Greg's
comments on scripts very valuable, and they often remind me to
check out the pages at http://mywiki.wooledge.org/BashGuide.
It would be exaggerating to say that I wait with bated breath for
Greg's comments whenever I post a script here myself.

Greg's criticism's are far more useful than some of the immaterial
English corrections I've seen here.

Cheers,
David.



Re: Script does not do what it is told to do

2019-10-25 Thread The Wanderer
On 2019-10-25 at 11:37, David Wright wrote:

> On Fri 25 Oct 2019 at 14:28:02 (+0100), Michael Howard wrote:
> 
>> On 25/10/2019 14:11, Greg Wooledge wrote:

>>> Untrue.  I pointed out the flaws last time this subject was
>>> discussed on this mailing list.  Was that just a few days ago, or
>>> was it last week?  I don't remember.
>> 
>> Sorry, but it _is_ true. One can't know, nor should one, if the 
>> variables and paths are correct, but if they are, i.e. all things 
>> being equal, the script  is inherrently correct. Of course, it 
>> certainly isn't optimal.
> 
> What's the role of the hyphen between the two --switches, please.

I'm not sure whether it can meaningfully serve this function in the
specific case given, but generally - particularly, IIRC, for GNU
programs - a standalone '-' means something like "treat the data you
receive from stdin as if it were the contents of an input file".

That wouldn't seem to fit too well with the use of the '-T' option,
which appears to mean "read the list of input filenames from the
specified file", but it's what I'd normally expect that syntax to mean.

-- 
   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man. -- George Bernard Shaw



signature.asc
Description: OpenPGP digital signature


Re: Script does not do what it is told to do

2019-10-25 Thread David Wright
On Fri 25 Oct 2019 at 11:49:46 (-0400), The Wanderer wrote:
> On 2019-10-25 at 11:37, David Wright wrote:
> > On Fri 25 Oct 2019 at 14:28:02 (+0100), Michael Howard wrote:
> >> On 25/10/2019 14:11, Greg Wooledge wrote:
> 
> >>> Untrue.  I pointed out the flaws last time this subject was
> >>> discussed on this mailing list.  Was that just a few days ago, or
> >>> was it last week?  I don't remember.
> >> 
> >> Sorry, but it _is_ true. One can't know, nor should one, if the 
> >> variables and paths are correct, but if they are, i.e. all things 
> >> being equal, the script  is inherrently correct. Of course, it 
> >> certainly isn't optimal.
> > 
> > What's the role of the hyphen between the two --switches, please.
> 
> I'm not sure whether it can meaningfully serve this function in the
> specific case given, but generally - particularly, IIRC, for GNU
> programs - a standalone '-' means something like "treat the data you
> receive from stdin as if it were the contents of an input file".
> 
> That wouldn't seem to fit too well with the use of the '-T' option,
> which appears to mean "read the list of input filenames from the
> specified file", but it's what I'd normally expect that syntax to mean.

Sure. - can indicate either of stdin or stdout when it follows -f,
stdin after -T, and so on. But I'm asking about its role in this
"correct script", and the earlier one where it doesn't even stand
alone. (There's no sign of redirection in either script.)

Cheers,
David.



Re: Script does not do what it is told to do

2019-10-25 Thread Michael Howard

On 25/10/2019 16:37, David Wright wrote:

On Fri 25 Oct 2019 at 14:28:02 (+0100), Michael Howard wrote:

On 25/10/2019 14:11, Greg Wooledge wrote:

On Fri, Oct 25, 2019 at 08:33:09AM +0100, Michael Howard wrote:

On 24/10/2019 23:37, Ken Heard wrote:

#!/bin/bash
# Script to back up all browser files in directory /home/ken/mozilla.
STARTDIR=$PWD
cd /home/ken
tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
- --wildcards -T docs/tarlists/kbrowsers.lst
cd "$STARTDIR"

There is nothing inherently wrong with the script,

Untrue.  I pointed out the flaws last time this subject was discussed
on this mailing list.  Was that just a few days ago, or was it last
week?  I don't remember.

Sorry, but it _is_ true. One can't know, nor should one, if the
variables and paths are correct, but if they are, i.e. all things
being equal, the script  is inherrently correct. Of course, it
certainly isn't optimal.

What's the role of the hyphen between the two --switches, please.


in that it would work if
all other things were equal, but they are clearly not.

Lots of scripts will work "if certain conditions hold true".

See above.

If one "shouldn't know" about such conditions, then it seems pointless
to post this sort of problem on the list. One is better employed in
checking one's own assumptions, as Thomas has shown elsewhere in the
thread.


That's the
fundamental problem here.  The script shown here is incredibly fragile,
and the author did not correct the flaws that I already pointed out
last time.  It may "work" under certain conditions.  How likely those
conditions are to be true, I have no way to know.

I have no idea about when or where the OP may have posted previously.

Four days ago, on this list. Looking back to check the date, I see
that the said hyphen had a different, but equally mysterious, role
in the OP's script back there. Perhaps you could explain that hyphen
at the same time.

https://lists.debian.org/debian-user/2019/10/msg00758.html


Using the -C option to tar is preferable to the way you are doing it.

Yup, that was one of the three(?) proposals I made last time around,
none of which were followed.  *shrug*  Not much more I can do when
nobody listens to me.

With your attitude, little wonder nobody listens to you. You're
probably on the ignore list :)

That might explain some of the scripts seen here. I find Greg's
comments on scripts very valuable, and they often remind me to
check out the pages at http://mywiki.wooledge.org/BashGuide.
It would be exaggerating to say that I wait with bated breath for
Greg's comments whenever I post a script here myself.

Greg's criticism's are far more useful than some of the immaterial
English corrections I've seen here.

Cheers,
David.


Well good for you. Nice to see Greg as a bodyguard.

plonk!

In case you don't know and to save you the time replying, that was the 
sound of you hitting the kill file.


Mike.

--




Re: Script does not do what it is told to do

2019-10-26 Thread Kushal Kumaran
Ken Heard  writes:

> Whenever I run this script -- or several others like it
>
> #!/bin/bash
> # Script to back up all browser files in directory /home/ken/mozilla.
> STARTDIR=$PWD
> cd /home/ken
> tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
> --wildcards -T docs/tarlists/kbrowsers.lst
> cd "$STARTDIR"
>
> it returns the following:
>
> ken@Turing:~$ tarkbrowsers
> tar (child): /media/ssda/backups/kbrowsers.tgz: Cannot open: No such
> file or directory
> tar (child): Error is not recoverable: exiting now
> tar: /media/ssda/backups/kbrowsers.tgz: Cannot write: Broken pipe
> tar: Child returned status 2
> tar: Error is not recoverable: exiting now
>
> It is trying to save the tarball to a different portable storage
> device, ssda, which had failed and consequently is no longer in
> /etc/fstab.  How could such a thing happen?
>

Please check the output of these commands:

which tarkbrowsers
cat $(which tarkbrowsers)

I suspect your invocation is not running the version of the script you
expect.

> However, if I pull the line with the tar command out of the script and
> running it independently it does what it is told.  If there is
> something wrong with the script I can't find it.
>
> I also tried the script with the second line reading STARTDIR="$PWD";
> but that change made no difference, the result was the same.
>

Try adding an "echo here" line at the beginning of the script and seeing
if that shows up.  If not, then you know for certain you are not running
what you think you are.

-- 
regards,
kushal



Re: Script does not do what it is told to do

2019-10-26 Thread Ken Heard
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I want at this time to thank all of you for taking the time to provide
various suggestions as to how to fix the problems I describe in my
original post and in my previous thread 'Signs of hard drive failure?'
My reason for the thank you is that early Monday morning 28 October I
am leaving for Thailand and will not be back in Toronto until
mid-April 2020 and so will not have time for any follow up before I
leave.

Consequently when my Toronto computer is closed tomorrow it will not
be opened or used for the next six months approximately. For those six
months I will be using my desktop computer in Thailand which will have
been idle from April 2019 to November 2019. I will however summarize
here what I have found out so far in Toronto.

With regard to possible hard disk failures, with the help of some of
you I found out that the internal two hard drives have some life left
in them.  What had failed however some of my backup portable devices,
a 1 tb portable USB hard drive and two of my six high capacity (32-64
tb) USB flash drives, all of which I use for back-ups.  What I think
had not failed was a SanDisk Extreme 500 (500 gb so they say, but
somewhat less) solid state USB portable drive.

So for my working files which I will be taking with me I am using one
of the 'good' 64 tb USB flash drives mount on /media/fde, and maybe
the the SanDisk on /media/ssda. My working files will be compressed
into some twenty tarballs written to the fde drive, but not on the
ssda for reasons explained below. I am also storing those tarballs in
Dropbox.

The scripts for these two devices follow.  Both are encrypted.
- --
#!/bin/bash
# Script to open and mount fde

sudo cryptsetup luksOpen UUID=26bb9cea-4ac0-47fa-838b-067baeb1936f fde
mount /media/fde
- --
#!/bin/bash
# Script to open and mount ssda

sudo cryptsetup luksOpen UUID=347eec80-ede8-4b10-bef6-24065ced3e97
ssda mount /media/ssda
- ---
As I had found that all these scripts could operate without changing
the working directory back and forth from /home/ken I removed from
them all the lines changing the working directories which shocked,
horrified and amazed many of you.

The first script above works; it can open the fde drive.  The second
one does not work, but it will work if the tar command is extracted
from the script and run independently in a virtual terminal.  (By the
way I have sudo set up to allow me to open every file without
password, as this is the only computer on the premises.)

The tar scripts now look like this.
- ---
#!/bin/bash
# Script to back up all browser files in directory /home/ken/mozilla.
echo here
tar -cpzf /media/fde/backups/kbrowsers.tgz  --exclude-caches
- --wildcards -T docs/tarlists/kbrowsers.lst
- ---
This one exceptionally has 'echo here" above the tar command at the
suggestion of Kushal Kumeran.  Also at his request I ran the following
two commands:
'which tarkbrowsers' which returned '/home/ken/bin/tarkbrowsers', and
'cat $(which tarkbrowsers)' which returned
- ---
# Script to back up all browser files in directory /home/ken/mozilla.
CURPWD=$PWD
cd /home/ken
tar -czf /media/ssda/backups/kbrowsers.tgz  --exclude-caches
- --wildcards -T docs/tarlists/kbrowsers.lst
cd $CURPWD
- ---
As this return includes the change of directories commands it is clear
that somewhere there is a series of extraneous scripts but the
software is being coy about telling me where they are.  As about a
fortnight ago all these scripts worked as they should have, it may be
possible that the ones which do not work now are those which I did not
change in the meantime.

So here is where the matter stands now.  I will be using these scripts
in Thailand and determine whether these idiosyncrasies occur there,
where I will have a buster machine instead of the stretch one I am
still using in Toronto.  So I may be on the thread again in Thailand,
and or possibly again in Toronto in April 2020.

Regards, Ken Heard







-BEGIN PGP SIGNATURE-

iF0EARECAB0WIQR9YFyM2lJAhDprmoOU2UnM6QmZNwUCXbTz8gAKCRCU2UnM6QmZ
N1ZGAJ9oiCkQsjTrdBa3HC5p5+CqybdO4ACeIex9comH1W7x1H3mbt7N1Tdm0pI=
=VKWL
-END PGP SIGNATURE-



Re: Script does not do what it is told to do

2019-10-26 Thread The Wanderer
On 2019-10-26 at 21:33, Ken Heard wrote:

> The tar scripts now look like this.
> ---
> #!/bin/bash
> # Script to back up all browser files in directory /home/ken/mozilla.
> echo here
> tar -cpzf /media/fde/backups/kbrowsers.tgz  --exclude-caches
> --wildcards -T docs/tarlists/kbrowsers.lst
> ---
> This one exceptionally has 'echo here" above the tar command at the
> suggestion of Kushal Kumeran.

Where is this script located (full path and filename)?

If I'm reading things right, you also might want to either put the 'cd
/home/ken' line back (no need for the other cd), or use the full path to
kbrowsers.lst instead of a relative path; otherwise this won't work
right if you run it from any directory which doesn't have that relative
path under it.

(If kbrowsers.lst has relative paths in it, this might not work
correctly from another location without the cd anyway, even if you do
use a full path on the command line. I don't have experience with that
tar feature myself.)

> Also at his request I ran the following two commands:
> 'which tarkbrowsers' which returned '/home/ken/bin/tarkbrowsers', and
> 'cat $(which tarkbrowsers)' which returned
> ---
> # Script to back up all browser files in directory /home/ken/mozilla.
> CURPWD=$PWD
> cd /home/ken
> tar -czf /media/ssda/backups/kbrowsers.tgz  --exclude-caches
> --wildcards -T docs/tarlists/kbrowsers.lst
> cd $CURPWD
> ---
> As this return includes the change of directories commands it is clear
> that somewhere there is a series of extraneous scripts but the
> software is being coy about telling me where they are.

Eh? No, it isn't. It already told you clearly that this latter script is
'/home/ken/bin/tarkbrowsers'.

Your mail doesn't (seem to?) give us enough information for us to
identify where the former of the two given scripts is, but presumably
you know where to find that one, since you were able to give its
contents here.

If you don't want to run this latter version of the script, either move
it out of its current directory (which is apparently in your PATH), or
replace it with the version you do want to run.


(I'm presuming that the newline between '--exclude-caches' and
'--wildcards' in each script is an artifact of the mail process, and not
present in the actual on-disk script. If it *is* present there, then
these are both going to break and not do what you expect.)

-- 
   The Wanderer may regret sending this, if recent history is any guide

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man. -- George Bernard Shaw



signature.asc
Description: OpenPGP digital signature


Re: Script does not do what it is told to do

2019-10-27 Thread Ken Heard
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 2019-10-26 9:55 p.m., The Wanderer wrote:
> On 2019-10-26 at 21:33, Ken Heard wrote:
> 
>> The tar scripts now look like this. 
>> --- 
>> #!/bin/bash # Script to back up all browser files in directory
>> /home/ken/mozilla. echo here tar -cpzf
>> /media/fde/backups/kbrowsers.tgz  --exclude-caches --wildcards -T
>> docs/tarlists/kbrowsers.lst 
>> --- This one
>> exceptionally has 'echo here" above the tar command at the 
>> suggestion of Kushal Kumeran.
> 
> Where is this script located (full path and filename)?
> 
> If I'm reading things right, you also might want to either put the
> 'cd /home/ken' line back (no need for the other cd), or use the
> full path to kbrowsers.lst instead of a relative path; otherwise
> this won't work right if you run it from any directory which
> doesn't have that relative path under it.
> 
> (If kbrowsers.lst has relative paths in it, this might not work 
> correctly from another location without the cd anyway, even if you
> do use a full path on the command line. I don't have experience
> with that tar feature myself.)
> 
>> Also at his request I ran the following two commands: 'which
>> tarkbrowsers' which returned '/home/ken/bin/tarkbrowsers', and 
>> 'cat $(which tarkbrowsers)' which returned 
>> --- # Script
>> to back up all browser files in directory /home/ken/mozilla. 
>> CURPWD=$PWD cd /home/ken tar -czf
>> /media/ssda/backups/kbrowsers.tgz  --exclude-caches --wildcards
>> -T docs/tarlists/kbrowsers.lst cd $CURPWD 
>> --- As this
>> return includes the change of directories commands it is clear 
>> that somewhere there is a series of extraneous scripts but the 
>> software is being coy about telling me where they are.
> 
> Eh? No, it isn't. It already told you clearly that this latter
> script is '/home/ken/bin/tarkbrowsers'.
> 
> Your mail doesn't (seem to?) give us enough information for us to 
> identify where the former of the two given scripts is, but
> presumably you know where to find that one, since you were able to
> give its contents here.
> 
> If you don't want to run this latter version of the script, either
> move it out of its current directory (which is apparently in your
> PATH), or replace it with the version you do want to run.
> 
> 
> (I'm presuming that the newline between '--exclude-caches' and 
> '--wildcards' in each script is an artifact of the mail process,
> and not present in the actual on-disk script. If it *is* present
> there, then these are both going to break and not do what you
> expect.)
> 
Thank you for your prompt response.  I understand what you mean about
full and relevant paths.  I will have to look into this issue; it may
affect the outcome of the script regardless of the computer as both
the Toronto and Thailand computers are set up the same way, with the
same paths, etc.

Regards, Ken

-BEGIN PGP SIGNATURE-

iF0EARECAB0WIQR9YFyM2lJAhDprmoOU2UnM6QmZNwUCXbWk7AAKCRCU2UnM6QmZ
N/WlAJ4+Nso8uo4X/wLXmj5TMvqSO0uMggCdEphMTf/xIiDxtAJbnQyUV/l/8vA=
=7+2G
-END PGP SIGNATURE-