Kamis, 06 Oktober 2016

Bristol Digest, Vol 664, Issue 5

Send Bristol mailing list submissions to
bristol@mailman.lug.org.uk

To subscribe or unsubscribe via the World Wide Web, visit
https://mailman.lug.org.uk/mailman/listinfo/bristol
or, via email, send a message with subject or body 'help' to
bristol-request@mailman.lug.org.uk

You can reach the person managing the list at
bristol-owner@mailman.lug.org.uk

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Bristol digest..."


Today's Topics:

1. Re: Auto Restarting script (david)
2. Re: Auto Restarting script (Shane McEwan)
3. Re: Bulk Exif date insertion - Perl error (David Smith)
4. Re: Bulk Exif date insertion - Perl error (Amias Channer)
5. Re: Bulk Exif date insertion - Perl error (Shane McEwan)
6. Re: Auto Restarting script (Amias Channer)
7. Re: Auto Restarting script (Martin Moore)


----------------------------------------------------------------------

Message: 1
Date: Thu, 06 Oct 2016 11:41:12 +0100
From: david <david@avoncliff.com>
To: bristol@mailman.lug.org.uk
Subject: Re: [bristol] Auto Restarting script
Message-ID: <57F62A48.3030702@avoncliff.com>
Content-Type: text/plain; charset=utf-8; format=flowed

On 06/10/16 11:08, Martin Moore via Bristol wrote:
> Yes – but how do I stop the process?
>

Use systemd to create a service ?

------------------------------

Message: 2
Date: Thu, 6 Oct 2016 11:44:57 +0100
From: Shane McEwan <shane@mcewan.id.au>
To: bristol@mailman.lug.org.uk
Subject: Re: [bristol] Auto Restarting script
Message-ID: <6d4e21dc-f3fe-d002-c6c0-5f7c24ff8507@mcewan.id.au>
Content-Type: text/plain; charset=utf-8; format=flowed

How do you stop it normally? Ctrl-C? If so, you can simulate a Ctrl-C
with the SIGTERM signal which you can send to the process with the kill
command. However, the kill command needs the process ID which you might
not have readily to hand.

Look at the 'pkill' command that will kill a process that matches a
particular pattern. If you can come up with a pattern that uniquely
matches the process then you can be sure you're only killing the right
thing.

Shane.

On 06/10/16 11:08, Martin Moore via Bristol wrote:
> Yes – but how do I stop the process?
>
>
> On 06/10/2016, 10:50, "Bristol on behalf of David Smith via Bristol" <bristol-bounces@mailman.lug.org.uk on behalf of bristol@mailman.lug.org.uk> wrote:
>
> > -----Original Message-----
> > From: Bristol [mailto:bristol-bounces@mailman.lug.org.uk] On Behalf Of
> > Martin Moore via Bristol
> > I've got a java prog that starts via a bash script. For reasons outside my
> > control, it sometimes needs stopping and restarting – I can check if this is
> > necessary using a cron job.
> >
> > So, how do I stop and restart the main script (from the cron task) ?
>
> Surely your cron job can just call a bash script, which can then do whatever you want?
>
> _______________________________________________
> Bristol mailing list
> Bristol@mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/bristol
>
>
>
> _______________________________________________
> Bristol mailing list
> Bristol@mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/bristol
>

------------------------------

Message: 3
Date: Thu, 6 Oct 2016 10:57:11 +0000
From: David Smith <David.Smith@imgtec.com>
To: Peter Hemmings <peternsomerset@virginmedia.com>, "Bristol and Bath
Linux User Group" <bristol@mailman.lug.org.uk>
Subject: Re: [bristol] Bulk Exif date insertion - Perl error
Message-ID:
<15A9D35B5490FC49AC0524AE3A085F082FCAECA9@HHMAIL01.hh.imgtec.org>
Content-Type: text/plain; charset="utf-8"

> -----Original Message-----
> From: Bristol [mailto:bristol-bounces@mailman.lug.org.uk] On Behalf Of
> Peter Hemmings via Bristol
> FYI when its run, it first complains about "website'$pix" only occurring once,
> then asks for name etc. then actuall runs and does the job OK.
>
> So another question is where does it get "my_website $pix"!?

Come on Peter, you know better than to post asking for help without quoting the actual error message ;-)

Without seeing the actual error message, I'm guessing that it's complaining about:

system("exiv2 -M'set Exif.Image.Artist $my_name $my_website' $pix");

is using the variable $my_website without that variable having previously being defined.

You could add the following to the stuff at the beginning:

print "Enter Your Website: ";
chomp($my_website = <>);

Or possibly just remove $my_website from the above system() call if you don't want to add a website into that tag.

------------------------------

Message: 4
Date: Thu, 6 Oct 2016 11:59:51 +0100
From: Amias Channer <me@amias.net>
To: Peter Hemmings <peternsomerset@virginmedia.com>, Bristol and Bath
Linux User Group <bristol@mailman.lug.org.uk>
Subject: Re: [bristol] Bulk Exif date insertion - Perl error
Message-ID:
<CAMgU7XVGB9hA7zjy+0Mk1WGAO7FsLbZ=NDBE_pOzOVd9z0C9LQ@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

Hello Peter,

This script doesnt set the variable $my_website.

You could either add another prompt for the data with these 2 lines ,
stick them below the enter the day prompt:

print "Enter the Website(URL): ";
chomp($my_website = <>);


or better still just define it $my_website = 'http://peterswebsite.com/'

I would suggest removing the user inputs ( the use of <> and chomp)
and just assigning the values directly so that it doesn't require user
input for each picture.

Cheers
Amias

------------------------------

Message: 5
Date: Thu, 6 Oct 2016 12:01:51 +0100
From: Shane McEwan <shane@mcewan.id.au>
To: bristol@mailman.lug.org.uk
Subject: Re: [bristol] Bulk Exif date insertion - Perl error
Message-ID: <23c5992e-8e5d-0189-e531-f97b06f94b3d@mcewan.id.au>
Content-Type: text/plain; charset=utf-8; format=flowed

The error you're getting is from the "@pix = `ls *.JPG *.jpg`;" line
which is trying to list all the JPG and jpg files in the current
directory. If all your files are ".jpg" and you don't have any ".JPG"
files then ls will complain that you don't have any JPG files:

ls: cannot access *.JPG: No such file or directory

As the author says, you can safely ignore the error. Or change that line
so that you're only listing extensions that actually match real files.

It's a very poorly written Perl script. The other warning you're getting
about $my_website only being used once is because of this line:

system("exiv2 -M'set Exif.Image.Artist $my_name $my_website' $pix");

And the warning is because that line is using a $my_website variable but
that variable isn't actually defined anywhere in the script! Because
Perl's strict mode isn't turned on this is just a warning and won't
affect the operation of the script.

To get rid of the warning simply delete the $my_website variable from
that line so it looks like this:

system("exiv2 -M'set Exif.Image.Artist $my_name' $pix");

Alternatively, you could prompt for a website by putting:

print "Enter Your Website: ";
chomp($my_website = <>);

. . . between the Name and Year prompts.

Hope this helps!

Shane.

On 06/10/16 11:21, Peter Hemmings via Bristol wrote:
> Hi,
>
> I have started to scan old transparencies onto my PC and have bulk
> renamed them OK with "Thunar" file manager.
> Before I import them I want to insert exif dates on groups of images.
>
> I have been trying exiv2 with a perl script to bulk insert. It does seem
> to work but throws up errors as the originator expected but I am curious
> to know where the problem is and if I can eliminate it!
>
> I know very little about perl but can get the idea of what the script does.
>
> Can anyone enlighten me as to if the problem is with exiv2 or the script
> and how I could make it work better?
>
> References:
>
> Actual Script:
>
> #!/usr/bin/perl -w
> #
> # ADDING DATES TO SCANNED PHOTOS OR NEGATIVES
> #
> # Kim Briggs 2009-12 http://kimbriggs.com
> #
> # Script uses the exiv2 program http://www.exiv2.org/
> # to add EXIF date and metadata to JPGS (and rename with new timestamp).
> #
> # Process ONE ROLL of film at a time (59 pics max).
> # Numbering sequence is from NOON, i.e., 120100 to 125900.
> #
> # Reference of EXIF format: Date Taken: 2009:10:07 15:24:02
> # ModifyDate=DateTime(EXIFspec)
> # CreateDate=DateTimeDigitized(EXIFspec)
> # DateTimeOriginal(ExifIFD)
> # exiv2 -pt = print all the exif tags to screen
> #
>
> print "Enter Your Name: ";
> chomp($my_name = <>);
>
> print "Enter the Year(YYYY): ";
> chomp($my_year = <>);
>
> print "Enter the Month(MM): ";
> chomp($my_month = <>);
>
> print "Enter the Day(DD): ";
> chomp($my_day = <>);
>
> # Load all jpgs into an array. Use the same suffix for all files to
> preserve your order.
> # There will be an error message about the suffix you didn't use. Ignore
> it.
> @pix = `ls *.JPG *.jpg`;
>
> $my_count = 0;
>
> foreach $pix (@pix) {
>
> if ($my_count < 10) {$my_count="0$my_count";}
>
> print "Processing photo: ".$pix;
> # Use the program exiv2 to process EXIF metadata and rename the file
> with timestamp
>
> system("exiv2 -M'set Exif.Image.Artist $my_name $my_website' $pix");
>
> system("exiv2 -M'set Exif.Image.Copyright Copyright $my_year $my_name.
> All Rights Reserved.' $pix");
>
> system("exiv2 -M'set Exif.Image.DateTime $my_year:$my_month:$my_day
> 12:$my_count:00' $pix");
>
> system("exiv2 -M'set Exif.Photo.DateTimeOriginal
> $my_year:$my_month:$my_day 12:$my_count:00' $pix");
>
> system("exiv2 -M'set Exif.Photo.DateTimeDigitized
> $my_year:$my_month:$my_day 12:$my_count:00' $pix");
>
> # Comment out the line below with a "#" symbol to AVOID RENAMING the file.
>
> system("exiv2 -r %Y_%m%d_%H%M%S $pix");
>
> $my_count = int($my_count) + 1;
> }
>
>
> http://www.exiv2.org/
> http://kimbriggs.com/computer/add-exif-date-scanned-photo-negative
>
> FYI when its run, it first complains about "website'$pix" only occurring
> once, then asks for name etc. then actuall runs and does the job OK.
>
> So another question is where does it get "my_website $pix"!?
>
>
>
> Thanks

------------------------------

Message: 6
Date: Thu, 6 Oct 2016 12:06:00 +0100
From: Amias Channer <me@amias.net>
To: Martin Moore <martinm@it-helps.co.uk>, Bristol and Bath Linux
User Group <bristol@mailman.lug.org.uk>
Subject: Re: [bristol] Auto Restarting script
Message-ID:
<CAMgU7XUE8f4N5OZ6zXGDZvTiWW6qaA77szSv4148_c3UnGNwPw@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

Hello Martin,

Normally these kind of scripts accept a single parameter which is start or stop

Usually the script that starts the process stores the PID of the
process it started in a file in /var/run/process_name.pid

When run with the stop parameter it would then read the file for the
PID and kill that process.

The start part of the script can also use the pid file to see if its
already running and refuse to start it twice.

Depending on how the java prog is implemented it might or might not
sensibly respond to signals from kill to close it self down.

You should have plenty of examples of this type of behaviour in
/etc/init.d/ , although newer distros have replaced this with systemd
which is subtly different

Cheers
Amias

On 6 October 2016 at 10:43, Martin Moore via Bristol
<bristol@mailman.lug.org.uk> wrote:
> I've got a java prog that starts via a bash script. For reasons outside my control, it sometimes needs stopping and restarting – I can check if this is necessary using a cron job.
>
> So, how do I stop and restart the main script (from the cron task) ?
>
>
> Cheers.
>
>
>
>
> _______________________________________________
> Bristol mailing list
> Bristol@mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/bristol

------------------------------

Message: 7
Date: Thu, 06 Oct 2016 12:08:55 +0100
From: Martin Moore <martinm@it-helps.co.uk>
To: Bristol and Bath Linux User Group <bristol@mailman.lug.org.uk>
Subject: Re: [bristol] Auto Restarting script
Message-ID: <B2859B43-FD21-4FCC-9CEE-6A58A9686C5F@it-helps.co.uk>
Content-Type: text/plain; charset="UTF-8"

pkill's perfect – cheers.

Martin.

On 06/10/2016, 11:44, "Bristol on behalf of Shane McEwan via Bristol" <bristol-bounces@mailman.lug.org.uk on behalf of bristol@mailman.lug.org.uk> wrote:

How do you stop it normally? Ctrl-C? If so, you can simulate a Ctrl-C
with the SIGTERM signal which you can send to the process with the kill
command. However, the kill command needs the process ID which you might
not have readily to hand.

Look at the 'pkill' command that will kill a process that matches a
particular pattern. If you can come up with a pattern that uniquely
matches the process then you can be sure you're only killing the right
thing.

Shane.

On 06/10/16 11:08, Martin Moore via Bristol wrote:
> Yes – but how do I stop the process?
>
>
> On 06/10/2016, 10:50, "Bristol on behalf of David Smith via Bristol" <bristol-bounces@mailman.lug.org.uk on behalf of bristol@mailman.lug.org.uk> wrote:
>
> > -----Original Message-----
> > From: Bristol [mailto:bristol-bounces@mailman.lug.org.uk] On Behalf Of
> > Martin Moore via Bristol
> > I've got a java prog that starts via a bash script. For reasons outside my
> > control, it sometimes needs stopping and restarting – I can check if this is
> > necessary using a cron job.
> >
> > So, how do I stop and restart the main script (from the cron task) ?
>
> Surely your cron job can just call a bash script, which can then do whatever you want?
>
> _______________________________________________
> Bristol mailing list
> Bristol@mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/bristol
>
>
>
> _______________________________________________
> Bristol mailing list
> Bristol@mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/bristol
>

_______________________________________________
Bristol mailing list
Bristol@mailman.lug.org.uk
https://mailman.lug.org.uk/mailman/listinfo/bristol

------------------------------

Subject: Digest Footer

_______________________________________________
Bristol mailing list
Bristol@mailman.lug.org.uk
https://mailman.lug.org.uk/mailman/listinfo/bristol

------------------------------

End of Bristol Digest, Vol 664, Issue 5
***************************************

Tidak ada komentar:

Posting Komentar