Re: [SOLVED] Re: Shell Script Help

2019-05-06 Thread Patrick Bartek
On Mon, 6 May 2019 15:16:09 -0500
David Wright  wrote:

> On Mon 06 May 2019 at 10:56:47 (-0700), Patrick Bartek wrote:
> > On Mon, 6 May 2019 13:08:05 -0400 Greg Wooledge  
> > wrote:  
> > > On Mon, May 06, 2019 at 09:41:58AM -0700, Patrick Bartek wrote:  
> > > > On Mon, 6 May 2019 10:24:24 -0400 Greg Wooledge  
> > > > wrote:
> > > > > for dir in ab*/; do
> > > > > name=${dir%/}
> > > > > enfuse --output "$name.jpg" --compression=97 "$dir"/*.jpg
> > > > > done
> > > > 
> > > > Typed in as a single line with a semi-colon at end of enfuse command
> > > > and before done to keep it from locking up, generates error "enfuse:
> > > > failed to open "ab*//*.jpg: No such file or directory. But it's a
> > > > beginning. Time to pull out my 400 page Unix shell programming book.
> > > 
> > > Most likely it means there weren't any matching directories wherever
> > > you ran it.  The ab*/ glob will be used literally if it doesn't match
> > > any directories.
> > > 
> > > If you want to check for that, you can add a test.
> > > 
> > > for dir in ab*/; do
> > > test -d "$dir" || continue
> > > name=${dir%/}
> > > enfuse --output "$name.jpg" --compression=97 "$dir"/*.jpg
> > > done
> > > 
> > > You said you had twenty-something directories named ab01, ab02, etc.
> > > So it should have matched unless you ran it from the wrong place,
> > > or unless you lied about your directory names.
> > > 
> > > But nobody would EVER lie about their directory names in a shell
> > > programming question.  Oh, no, never.  
> > 
> > Silly me.  I failed to substitute the correct dir name letters in the
> > script for example "ab" prefix I origninaly posted. Didn"t even notice
> > until I started troubleshooting 3 hours later. That's what I get for
> > reading the list a 6:00am. With semi-colons properly placed for a one
> > liner, it works.  
> 
> You don't really need to place semicolons anywhere for a one-liner;
> the system does it for you. I've cut and pasted Greg's example into
> the command line, and then pressed Uparrow (for history recall):
> 
> $ for dir in ab*/; do
> > name=${dir%/}
> > enfuse --output "$name.jpg" --compression=97 "$dir"/*.jpg
> > done  
> bash: enfuse: command not found
> $ for dir in ab*/; do name=${dir%/}; enfuse --output "$name.jpg" 
> --compression=97 "$dir"/*.jpg; done
> 
> and there's your one-liner.

I come from a time when "The System" did nothing for you.  If you
missed a period or semi-colon, etc. execution stopped and, if you were
lucky, you got a cryptic error code number with no other explanation.
Hell, my Unix shell programming book is almost 30 years old! And it's
one of the newer ones. ;-)

But thanks for the info anyway.

B



Re: [SOLVED] Re: Shell Script Help

2019-05-06 Thread David Wright
On Mon 06 May 2019 at 10:56:47 (-0700), Patrick Bartek wrote:
> On Mon, 6 May 2019 13:08:05 -0400 Greg Wooledge  wrote:
> > On Mon, May 06, 2019 at 09:41:58AM -0700, Patrick Bartek wrote:
> > > On Mon, 6 May 2019 10:24:24 -0400 Greg Wooledge  
> > > wrote:  
> > > > for dir in ab*/; do
> > > > name=${dir%/}
> > > > enfuse --output "$name.jpg" --compression=97 "$dir"/*.jpg
> > > > done  
> > > 
> > > Typed in as a single line with a semi-colon at end of enfuse command
> > > and before done to keep it from locking up, generates error "enfuse:
> > > failed to open "ab*//*.jpg: No such file or directory. But it's a
> > > beginning. Time to pull out my 400 page Unix shell programming book.  
> > 
> > Most likely it means there weren't any matching directories wherever
> > you ran it.  The ab*/ glob will be used literally if it doesn't match
> > any directories.
> > 
> > If you want to check for that, you can add a test.
> > 
> > for dir in ab*/; do
> > test -d "$dir" || continue
> > name=${dir%/}
> > enfuse --output "$name.jpg" --compression=97 "$dir"/*.jpg
> > done
> > 
> > You said you had twenty-something directories named ab01, ab02, etc.
> > So it should have matched unless you ran it from the wrong place,
> > or unless you lied about your directory names.
> > 
> > But nobody would EVER lie about their directory names in a shell
> > programming question.  Oh, no, never.
> 
> Silly me.  I failed to substitute the correct dir name letters in the
> script for example "ab" prefix I origninaly posted. Didn"t even notice
> until I started troubleshooting 3 hours later. That's what I get for
> reading the list a 6:00am. With semi-colons properly placed for a one
> liner, it works.

You don't really need to place semicolons anywhere for a one-liner;
the system does it for you. I've cut and pasted Greg's example into
the command line, and then pressed Uparrow (for history recall):

$ for dir in ab*/; do
> name=${dir%/}
> enfuse --output "$name.jpg" --compression=97 "$dir"/*.jpg
> done
bash: enfuse: command not found
$ for dir in ab*/; do name=${dir%/}; enfuse --output "$name.jpg" 
--compression=97 "$dir"/*.jpg; done

and there's your one-liner.

Cheers,
David.



Re: Shell Script Help

2019-05-06 Thread Dan Purgert
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Greg Wooledge wrote:
> [...]
> You said you had twenty-something directories named ab01, ab02, etc.
> So it should have matched unless you ran it from the wrong place,
> or unless you lied about your directory names.
>
> But nobody would EVER lie about their directory names in a shell
> programming question.  Oh, no, never.

- From the book of bashisms, verse 10:

  All examples given by the questioner will be broken, misleading,
  wrong, incomplete, and/or not representative of the actual question.

Thus sayeth the leaden feline. :)  

-BEGIN PGP SIGNATURE-

iQEzBAEBCAAdFiEEBcqaUD8uEzVNxUrujhHd8xJ5ooEFAlzQdLwACgkQjhHd8xJ5
ooHkrQgAnM5ONF1FsghmSKoeisYMukEN/Aq2bJlOjYWCo2F++uZm8/paMpv6UE4J
TDmilhYwKiyZVgvewSezeKv2CSkOU2gvwfEioKaX7riKY97Vd4cRysJPy5Pk6Yaj
Iv+apfmpGb+FaZt3Bw2jeZYqEBeZaGvhAC/YKnLexsrcBmsLtwrTWd+EpivKLtUu
8dXH3XPTjvI9S7ZT2Cf8lzlXsQ58LV6K0zTeSTuDjAoFenkxthSReMTHaz4tppDk
F58h+XOatqqUDceBfDh4aM48kHb9mHP9KpN56JWpSjCiDfuEx86EnkQHWlzwR4cM
c+n0iFbFh21NFxfU/nQig/uZfT5EsA==
=LRX7
-END PGP SIGNATURE-

-- 
|_|O|_| 
|_|_|O| Github: https://github.com/dpurgert
|O|O|O| PGP: 05CA 9A50 3F2E 1335 4DC5  4AEE 8E11 DDF3 1279 A281



[SOLVED] Re: Shell Script Help

2019-05-06 Thread Patrick Bartek
On Mon, 6 May 2019 13:08:05 -0400
Greg Wooledge  wrote:

> On Mon, May 06, 2019 at 09:41:58AM -0700, Patrick Bartek wrote:
> > On Mon, 6 May 2019 10:24:24 -0400
> > Greg Wooledge  wrote:  
> > > for dir in ab*/; do
> > > name=${dir%/}
> > > enfuse --output "$name.jpg" --compression=97 "$dir"/*.jpg
> > > done  
> > 
> > Typed in as a single line with a semi-colon at end of enfuse command
> > and before done to keep it from locking up, generates error "enfuse:
> > failed to open "ab*//*.jpg: No such file or directory. But it's a
> > beginning. Time to pull out my 400 page Unix shell programming book.  
> 
> Most likely it means there weren't any matching directories wherever
> you ran it.  The ab*/ glob will be used literally if it doesn't match
> any directories.
> 
> If you want to check for that, you can add a test.
> 
> for dir in ab*/; do
> test -d "$dir" || continue
> name=${dir%/}
> enfuse --output "$name.jpg" --compression=97 "$dir"/*.jpg
> done
> 
> You said you had twenty-something directories named ab01, ab02, etc.
> So it should have matched unless you ran it from the wrong place,
> or unless you lied about your directory names.
> 
> But nobody would EVER lie about their directory names in a shell
> programming question.  Oh, no, never.

Silly me.  I failed to substitute the correct dir name letters in the
script for example "ab" prefix I origninaly posted. Didn"t even notice
until I started troubleshooting 3 hours later. That's what I get for
reading the list a 6:00am. With semi-colons properly placed for a one
liner, it works.

Thanks.

B



Re: Shell Script Help

2019-05-06 Thread Greg Wooledge
On Mon, May 06, 2019 at 09:41:58AM -0700, Patrick Bartek wrote:
> On Mon, 6 May 2019 10:24:24 -0400
> Greg Wooledge  wrote:
> > for dir in ab*/; do
> > name=${dir%/}
> > enfuse --output "$name.jpg" --compression=97 "$dir"/*.jpg
> > done
> 
> Typed in as a single line with a semi-colon at end of enfuse command
> and before done to keep it from locking up, generates error "enfuse:
> failed to open "ab*//*.jpg: No such file or directory. But it's a
> beginning. Time to pull out my 400 page Unix shell programming book.

Most likely it means there weren't any matching directories wherever
you ran it.  The ab*/ glob will be used literally if it doesn't match
any directories.

If you want to check for that, you can add a test.

for dir in ab*/; do
test -d "$dir" || continue
name=${dir%/}
enfuse --output "$name.jpg" --compression=97 "$dir"/*.jpg
done

You said you had twenty-something directories named ab01, ab02, etc.
So it should have matched unless you ran it from the wrong place,
or unless you lied about your directory names.

But nobody would EVER lie about their directory names in a shell
programming question.  Oh, no, never.



Re: Shell Script Help

2019-05-06 Thread Patrick Bartek
On Mon, 6 May 2019 18:12:55 +0200
john doe  wrote:

> On 5/6/2019 4:24 PM, Greg Wooledge wrote:
> > On Mon, May 06, 2019 at 06:57:00AM -0700, Patrick Bartek wrote:  
> >> I want a script that allows commandline only applications that can't batch
> >> process to batch process.  A speciifc example. I will use the app
> >> enfuse, an exposure merging program, a poor man's HDR.
> >>
> >> patrick@Debian9:~/Work$ enfuse --output ab01.jpg --compression=97 
> >> ab01/DSC*.jpg
> >> patrick@Debian9:~/Work$ enfuse --output ab02.jpg --compression=97 
> >> ab02/DSC*.jpg
> >> :
> >> :
> >> patrick@Debian9:~/Work$ enfuse --output ab26.jpg --compression=97 
> >> ab26/DSC*.jpg
> >>
> >> I use shell history to repeat the command for each directory, changing the
> >>  --output filename and target directory numbers as necessary. Each 
> >> diretory already
> >> holds the appropriate image files.  
> >
> > for dir in ab*/; do
> > name=${dir%/}
> > enfuse --output "$name.jpg" --compression=97 "$dir"/*.jpg
> > done
> >  
> 
> Putting the above as a one liner:
> 
> $ for dir in ab*/; do name=${dir%/}; enfuse --output "$name.jpg"
 ^
> --compression=97 "$dir"/*.jpg; done
   ^
I added those semi-colons just as you did to make it one liner correct:
Same error.

Time to troubleshoot. I hope it's just a syntax error somewhere.

Thanks for your reply.

B



Re: Shell Script Help

2019-05-06 Thread Patrick Bartek
On Mon, 6 May 2019 10:24:24 -0400
Greg Wooledge  wrote:

> On Mon, May 06, 2019 at 06:57:00AM -0700, Patrick Bartek wrote:
> > I want a script that allows commandline only applications that can't batch
> > process to batch process.  A speciifc example. I will use the app
> > enfuse, an exposure merging program, a poor man's HDR.
> > 
> > patrick@Debian9:~/Work$ enfuse --output ab01.jpg --compression=97 
> > ab01/DSC*.jpg
> > patrick@Debian9:~/Work$ enfuse --output ab02.jpg --compression=97 
> > ab02/DSC*.jpg
> > :
> > :
> > patrick@Debian9:~/Work$ enfuse --output ab26.jpg --compression=97 
> > ab26/DSC*.jpg
> > 
> > I use shell history to repeat the command for each directory, changing the
> >  --output filename and target directory numbers as necessary. Each diretory 
> > already
> > holds the appropriate image files.  
> 
> for dir in ab*/; do
> name=${dir%/}
> enfuse --output "$name.jpg" --compression=97 "$dir"/*.jpg
> done
> 

Typed in as a single line with a semi-colon at end of enfuse command
and before done to keep it from locking up, generates error "enfuse:
failed to open "ab*//*.jpg: No such file or directory. But it's a
beginning. Time to pull out my 400 page Unix shell programming book.

Thanks.

B



Re: Shell Script Help

2019-05-06 Thread john doe
On 5/6/2019 4:24 PM, Greg Wooledge wrote:
> On Mon, May 06, 2019 at 06:57:00AM -0700, Patrick Bartek wrote:
>> I want a script that allows commandline only applications that can't batch
>> process to batch process.  A speciifc example. I will use the app
>> enfuse, an exposure merging program, a poor man's HDR.
>>
>> patrick@Debian9:~/Work$ enfuse --output ab01.jpg --compression=97 
>> ab01/DSC*.jpg
>> patrick@Debian9:~/Work$ enfuse --output ab02.jpg --compression=97 
>> ab02/DSC*.jpg
>> :
>> :
>> patrick@Debian9:~/Work$ enfuse --output ab26.jpg --compression=97 
>> ab26/DSC*.jpg
>>
>> I use shell history to repeat the command for each directory, changing the
>>  --output filename and target directory numbers as necessary. Each diretory 
>> already
>> holds the appropriate image files.
>
> for dir in ab*/; do
> name=${dir%/}
> enfuse --output "$name.jpg" --compression=97 "$dir"/*.jpg
> done
>

Putting the above as a one liner:

$ for dir in ab*/; do name=${dir%/}; enfuse --output "$name.jpg"
--compression=97 "$dir"/*.jpg; done


Note that this e-mail is folded by my mailer.

--
John Doe



Re: Shell Script Help

2019-05-06 Thread Greg Wooledge
On Mon, May 06, 2019 at 06:57:00AM -0700, Patrick Bartek wrote:
> I want a script that allows commandline only applications that can't batch
> process to batch process.  A speciifc example. I will use the app
> enfuse, an exposure merging program, a poor man's HDR.
> 
> patrick@Debian9:~/Work$ enfuse --output ab01.jpg --compression=97 
> ab01/DSC*.jpg
> patrick@Debian9:~/Work$ enfuse --output ab02.jpg --compression=97 
> ab02/DSC*.jpg
> :
> :
> patrick@Debian9:~/Work$ enfuse --output ab26.jpg --compression=97 
> ab26/DSC*.jpg
> 
> I use shell history to repeat the command for each directory, changing the
>  --output filename and target directory numbers as necessary. Each diretory 
> already
> holds the appropriate image files.

for dir in ab*/; do
name=${dir%/}
enfuse --output "$name.jpg" --compression=97 "$dir"/*.jpg
done



Re: Shell Script Help

2019-05-06 Thread Patrick Bartek
On Sat, 4 May 2019 17:54:28 -0700
Will Mengarini  wrote:

> * Patrick Bartek  [19-05/04=Sa 08:08 -0700]:
> > [...] Perform an operation on files in unique, sequential
> > directories [...] never more than 99 -- usually a lot
> > less.  The actual number will vary job to job.  [...]  
> 
> If the sequentially-numbered directories already exist:
>   `man find`
> Else:
>   for ((i=1;i<12;++i));{ printf frob%02d\\n $i;} # tested: Bash 3 & 4
> 
> [snip]

Thanks.  That helpts.

B



Re: Shell Script Help

2019-05-06 Thread Patrick Bartek
On Sat, 4 May 2019 15:34:16 -0500
Richard Owlett  wrote:

> On 05/04/2019 10:08 AM, Patrick Bartek wrote:
> > Hi! All,
> > 
> > Want to create a simple, one liner to type in to automate what I've
> > been doing manually:  [*SNIP*]  
> 
> I think the critical question is,> *WHAT* do you wish to accomplish?

Perhaps you're right.  I was too general in my initial query which made
it very unclear.

I want a script that allows commandline only applications that can't batch
process to batch process.  A speciifc example. I will use the app
enfuse, an exposure merging program, a poor man's HDR.

patrick@Debian9:~/Work$ enfuse --output ab01.jpg --compression=97 ab01/DSC*.jpg
patrick@Debian9:~/Work$ enfuse --output ab02.jpg --compression=97 ab02/DSC*.jpg
:
:
patrick@Debian9:~/Work$ enfuse --output ab26.jpg --compression=97 ab26/DSC*.jpg

I use shell history to repeat the command for each directory, changing the
 --output filename and target directory numbers as necessary. Each diretory 
already
holds the appropriate image files.

Thanks

B



Re: Shell Script Help

2019-05-06 Thread Patrick Bartek
On Sat, 4 May 2019 20:21:03 +0200
john doe  wrote:

> On 5/4/2019 5:08 PM, Patrick Bartek wrote:
> > Hi! All,
> >
> > Want to create a simple, one liner to type in to automate what I've
> > been doing manually: Perform an operation on files in unique,
> > sequential directories, save the results of the operations for each
> > directory with a file name of that directory in the directory the
> > target directories reside in.  For example:
> >
> > Directories ab01, ab02 ... ab30 results in output
> >
> > ab01.jpg. ab02.jpg ... ab30.jpg outside of those drectories.
> >
> > There will never be more than 99 directories -- usually a lot less. The
> > actual number will vary job to job. The letters in the directory names
> > will vary job to job, but will remain constant for each job.  Only the
> > numbers will sequence.
> >  
> 
> Would something like the following do it:
> 
> $ mkdir -p abc; cp -v abc*.gpg abc/ | tee -a abc/abc.log

Not for what I'm wanting -- See reply to Richard Ownes -- but for
something else I'm working on, yes.

Thanks

B



Re: Shell Script Help

2019-05-04 Thread Will Mengarini
* Patrick Bartek  [19-05/04=Sa 08:08 -0700]:
> [...] Perform an operation on files in unique, sequential
> directories [...] never more than 99 -- usually a lot
> less.  The actual number will vary job to job.  [...]

If the sequentially-numbered directories already exist:
  `man find`
Else:
  for ((i=1;i<12;++i));{ printf frob%02d\\n $i;} # tested: Bash 3 & 4

* Patrick Bartek  [19-05/04=Sa 08:08 -0700]:
> Want to create a simple, one liner to type in to automate what I've
> been doing manually: Perform an operation on files in unique,
> sequential directories, save the results of the operations for each
> directory with a file name of that directory in the directory the
> target directories reside in.  For example:
> 
> Directories ab01, ab02 ... ab30 results in output
> 
> ab01.jpg. ab02.jpg ... ab30.jpg outside of those drectories.
> 
> There will never be more than 99 directories -- usually a lot less. The
> actual number will vary job to job. The letters in the directory names
> will vary job to job, but will remain constant for each job.  Only the
> numbers will sequence. 



Re: Shell Script Help

2019-05-04 Thread Richard Owlett

On 05/04/2019 10:08 AM, Patrick Bartek wrote:

Hi! All,

Want to create a simple, one liner to type in to automate what I've
been doing manually:  [*SNIP*]


I think the critical question is,> *WHAT* do you wish to accomplish?






Re: Shell Script Help

2019-05-04 Thread john doe
On 5/4/2019 5:08 PM, Patrick Bartek wrote:
> Hi! All,
>
> Want to create a simple, one liner to type in to automate what I've
> been doing manually: Perform an operation on files in unique,
> sequential directories, save the results of the operations for each
> directory with a file name of that directory in the directory the
> target directories reside in.  For example:
>
> Directories ab01, ab02 ... ab30 results in output
>
> ab01.jpg. ab02.jpg ... ab30.jpg outside of those drectories.
>
> There will never be more than 99 directories -- usually a lot less. The
> actual number will vary job to job. The letters in the directory names
> will vary job to job, but will remain constant for each job.  Only the
> numbers will sequence.
>

Would something like the following do it:

$ mkdir -p abc; cp -v abc*.gpg abc/ | tee -a abc/abc.log

--
John Doe



Shell Script Help

2019-05-04 Thread Patrick Bartek
Hi! All,

Want to create a simple, one liner to type in to automate what I've
been doing manually: Perform an operation on files in unique,
sequential directories, save the results of the operations for each
directory with a file name of that directory in the directory the
target directories reside in.  For example:

Directories ab01, ab02 ... ab30 results in output

ab01.jpg. ab02.jpg ... ab30.jpg outside of those drectories.

There will never be more than 99 directories -- usually a lot less. The
actual number will vary job to job. The letters in the directory names
will vary job to job, but will remain constant for each job.  Only the
numbers will sequence. 

Any help is appreciated.

Thanks.

B



Automatic Backup Script Help

2012-05-23 Thread Craig A. Adams

Hi,

I am trying to setup a basic backup script for a Debian 6.0.5 server and 
am wanting to validate the scripts I have so far.


Here is the scenario...

The server has 2 x 1Tb hard drives in RAID 1 config. A third 1Tb hard 
drive is used for scheduled rsync snapshots.


I also have 5 x USB 3.0 1Tb hard drives for taking backups off site.

The aim is to plug one of the external hard drives and rsync the 
snapshot backup to it automatically.


Using udev rules I now have the hard drives being recognised on plug in 
and udev firing off a test script.


As it is not a good idea to block up udev by running the backup script 
from the udev rule, I need a staging script to start the backup, but not 
immediately.


The backup script is intended to be run 1 minute after the external hard 
drive is plugged in, and this is what I have come up with:


Staging Script
==

/data/backups/scripts/start-disk-1.sh
#!/bin/bash
echo /data/backups/scripts/backup-disk-1.sh | at now + 1 minute

Is this the correct way to call the backup script, or is there a better way?

Backup Script
=

Now the backup script needs to do certain things.

1) Mount the hard drive and fail if necessary.
2) Carry out the rsync to the external hard drive.
3) Unmount the external hard drive.
4) Generate a log of the backup process.
4) Send an email with the log as the message body.

I have not figured out how to generate the log.
I am not sure of my script syntax including  vs ' vs ` delimiters.

The actual backup script I have come up with is as follows... (I hope 
email line wrapping doesn't ruin the script layout.)


/data/backups/scripts/backup-disk-1.sh
#!/bin/bash
# Backup to Disk 1

# Set Variables for Script

backup_description=Disk-1
backup_source='/data/snapshots/'
backup_target='/data/backups/disk-1'
start_date_time='date +%Y-%m-%d-%H:%M:%S'
from_addr='x...@abc.com'
to_addr='a...@xyz.com'
cc_addr='d...@uvw.com
subject='${backup_description} backup at ${current_date_time}'
smtp_server='smtp.somewhere.com'
user_name='x...@abc.com'
mail_pwd='password'
backup_log_file='/data/backup/logs/${backup_description}-${start_date_time}.log'

# Check if another backup is already in progress. If not, create a 
progress file, else fail.


if -a /data/backups/${backup_description}-in-progress; then
echo FAIL ${backup_description} backup already in progress.
exit 1
else touch /data/backups/${backup_description}-in-progress
fi

# Start disk mount process

echo ${backup_description} Automatic Backup Starting at ${start_date_time}

# Check and mount hard drive if not already mounted.

if ! mountpoint -q ${backup_target}/; then
echo Mounting the external hard drive.
echo External hard drive mounted at ${backup_target}
if ! mount ${backup_target}; then
echo FAILURE! An error was returned during mounting of hard 
drive.
rm /data/backups/${backup_description}-in-progress
exit 1
else echo External hard drive mounted successfully.;
fi
else echo ${backup_target} is already mounted, but should not be. Check 
logs!;

fi

# If hard drive is still not mounted, exit ungracefully

if ! mountpoint -q ${backup_target}/; then
echo FAILURE! Mounting of external hard drive failed!
rm /data/backups/${backup_description}-in-progress
exit 1
fi

# Start actual rsync backup

echo Start of rsync backup.
sudo rsync --archive --verbose --human-readable --itemize-changes 
--progress --delete ${backup_source} ${backup_target}/


# Remove backup in progress file

rm /data/backups/${backup_description}-in-progress

# Unmount external hard drive

umount ${backup_target}

# Set backup finish time

finish_date_time='date +%Y-%m-%d-%H:%M:%S'

# End of backup message

echo ${backup_description} Automatic Backup finished at 
${finish_date_time}.


# Send eMail Log of backup

sendemail -f ${from_addr} -t ${to_addr} -u ${subject} -m 
${backup_log_file} -s ${smtp_server} -cc ${cc_addr} -xu ${user_name} -xp 
${password}


Any help with this would be gratefully received.

Kindest Regards

Craig A. Adams


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org

Archive: http://lists.debian.org/4fbc8405.3020...@iafrica.com



Re: Automatic Backup Script Help

2012-05-23 Thread Jon Dowland
On Wed, May 23, 2012 at 08:30:29AM +0200, Craig A. Adams wrote:
 /data/backups/scripts/start-disk-1.sh
 #!/bin/bash
 echo /data/backups/scripts/backup-disk-1.sh | at now + 1 minute
 
 Is this the correct way to call the backup script, or is there a better way?

It doesn't seem like a bad idea; especially since you get some extras from at
(e.g. mail error output to user) for free. Another approach would be

  { sleep 60; /data/backups/scripts/backup-disk-1.sh } 

But I don't see why you even need the sleep.

 start_date_time='date +%Y-%m-%d-%H:%M:%S'

should be backticks here so that date is evaluated e.g.

start_date_time=`date +%Y-%m-%d-%H:%M:%S`

 if -a /data/backups/${backup_description}-in-progress; then
   echo FAIL ${backup_description} backup already in progress.
   exit 1
 else touch /data/backups/${backup_description}-in-progress
 fi

There is a risk of race conditions here, if two instances of your script
are fired off at similar times. E.g., whilst instance #1 has performed
the check, instance #2 creates the file…  Better would be a proper locking
solution. (sorry I'm not offering one in this reply)

 if ! mountpoint -q ${backup_target}/; then

risk of races here

   if ! mount ${backup_target}; then

and here



-- 
Jon Dowland


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20120523071200.GA28792@debian



Re: Automatic Backup Script Help

2012-05-23 Thread Craig A. Adams

Thank you for the feedback Jon. :-)

On 23/05/2012 09:12 AM, Jon Dowland wrote:

   { sleep 60; /data/backups/scripts/backup-disk-1.sh }

But I don't see why you even need the sleep.


I agree. I suspect using sleep will merely suspend udev operations as well.


should be backticks here so that date is evaluated e.g.

start_date_time=`date +%Y-%m-%d-%H:%M:%S`


Thank you. Not being an experiences bash scripter, I always seem to get 
lost on the proper delimeters.





if -a /data/backups/${backup_description}-in-progress; then
echo FAIL ${backup_description} backup already in progress.
exit 1
else touch /data/backups/${backup_description}-in-progress
fi


There is a risk of race conditions here, if two instances of your script
are fired off at similar times. E.g., whilst instance #1 has performed
the check, instance #2 creates the file…  Better would be a proper locking
solution. (sorry I'm not offering one in this reply)


That is what I am trying to achieve by the progress file. I have noticed 
that sometimes with usb, the device is discovered multiple times. So I 
want to prevent multiple instances of the script. I will obviously need 
to find a better locking mechanism.





if ! mountpoint -q ${backup_target}/; then


risk of races here


if ! mount ${backup_target}; then


and here



I am lost here. I thought that this would be a simple mountpoint check. 
Is there a better way to mount and check if the drive is mounted?


Kindest Regards

Craig A. Adams



--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org

Archive: http://lists.debian.org/4fbc92fd.9000...@iafrica.com



Re: Automatic Backup Script Help

2012-05-23 Thread Kushal Kumaran
On Wed, May 23, 2012 at 1:04 PM, Craig A. Adams crai...@iafrica.com wrote:
 Thank you for the feedback Jon. :-)


 On 23/05/2012 09:12 AM, Jon Dowland wrote:

   { sleep 60; /data/backups/scripts/backup-disk-1.sh }

 But I don't see why you even need the sleep.


 I agree. I suspect using sleep will merely suspend udev operations as well.


 should be backticks here so that date is evaluated e.g.

 start_date_time=`date +%Y-%m-%d-%H:%M:%S`


 Thank you. Not being an experiences bash scripter, I always seem to get lost
 on the proper delimeters.



 if -a /data/backups/${backup_description}-in-progress; then
        echo FAIL ${backup_description} backup already in progress.
        exit 1
 else touch /data/backups/${backup_description}-in-progress
 fi


 There is a risk of race conditions here, if two instances of your script
 are fired off at similar times. E.g., whilst instance #1 has performed
 the check, instance #2 creates the file…  Better would be a proper locking
 solution. (sorry I'm not offering one in this reply)


 That is what I am trying to achieve by the progress file. I have noticed
 that sometimes with usb, the device is discovered multiple times. So I
 want to prevent multiple instances of the script. I will obviously need to
 find a better locking mechanism.


flock from the util-linux package:

FLOCK(1)

NAME
   flock - manage locks from shell scripts

SYNOPSIS
   flock [-sxon] [-w timeout] lockfile [-c] command...

   flock [-sxon] [-w timeout] lockdir [-c] command...

   flock [-sxun] [-w timeout] fd



 if ! mountpoint -q ${backup_target}/; then


 risk of races here

        if ! mount ${backup_target}; then


 and here


 I am lost here. I thought that this would be a simple mountpoint check. Is
 there a better way to mount and check if the drive is mounted?



-- 
regards,
kushal


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/CAH8GtdNnz5Lsh8LeLkvFY=ox55mhf6dr2v3_stea6+ed-rf...@mail.gmail.com



renamer script help..

2010-02-21 Thread Vadkan Jozsef
The script:
http://pastebin.ca/1804613

but it's not working too well:
http://pastebin.ca/1804612

e.g.: the script makes arviztur-ukorfurogep from árvíztűrő
tükörfúrógép, when it should be: arvizturo-tukorfurogep

Has someone a similar script, that works?

thanks:\
ps.: i tried it under lucid, dash is not installed as /bin/sh..


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/1266759944.6612.12.ca...@ubuntu



postfix+sasl+dovecot script help!

2009-11-26 Thread Tudod Ki
postfix+sasl+dovecot script help!

Hi everybody!

I am trying to get the solution for days now, and I don't know what to do 
really :S

I just want to write a script, what does automatically install postfix, 
dovecot, and it configures sasl authentication for the clients.

I'm here right now [the script!!]:



http://pastebin.ca/1687824

[I have written the reference howto in the script.]



I run it after a fresh Lenny netinstall, on VirtualBox.

If someone knows, what am I missing, please help me :\

I can see with netstat -tulpn, that the server is listeing on port 993,955,25.



1.) But: when I want to get the e-mails through imap, with Thunderbird, on 
another machine, it just waits, and waits, and waits...[and finally it gives 
this: Connection to server debian.lan timed out.] :\

logs:
mail.info log: http://pastebin.com/f6c486374
mail.log: http://pastebin.com/f6e60f9b
other logs are empty



2.) When I want to send a message from a testuser to a testuser, with 
Thunderbird, on the client, it just keeps asking for the password, when I want 
click send. :S

logs:
mail.info: http://pastebin.com/f1bca774f
mail.log: http://pastebin.com/f5c0be27c
mail.warn: http://pastebin.com/f46806d2f
other logs are empty



Info about the os  softwares [e.g.: dpkg -l | grep postfix]: 
http://pastebin.com/f1d0cefd2

192.168.56.4 is the client
192.168.56.5 is the server
[VirtualBox, Host-Only networking, they can ping each other]



Later I want to use it with Squirrel Mail [plus spam filtering + antivirus], 
but first, I just want to get it work :(

Thank you for any help :S [_good_ docs, howtos, solution, or anything please! 
:S :( ]


  

Re: postfix+sasl+dovecot script help!

2009-11-26 Thread Didar Hossain
On Thu, Nov 26, 2009 at 3:20 PM, Tudod Ki tudodk...@yahoo.com wrote:

 postfix+sasl+dovecot script help!

 Hi everybody!

 I am trying to get the solution for days now, and I don't know what to do 
 really :S

 I just want to write a script, what does automatically install postfix, 
 dovecot, and it configures sasl authentication for the clients.

 I'm here right now [the script!!]:

 

 http://pastebin.ca/1687824

 [I have written the reference howto in the script.]

 

 I run it after a fresh Lenny netinstall, on VirtualBox.

 If someone knows, what am I missing, please help me :\

 I can see with netstat -tulpn, that the server is listeing on port 
 993,955,25.

 

 1.) But: when I want to get the e-mails through imap, with Thunderbird, on 
 another machine, it just waits, and waits, and waits...[and finally it gives 
 this: Connection to server debian.lan timed out.] :\

Use openssl s_client -connect debian.lan:995 to perform a test POP3
session and verify whether you are able to connect to the POP3
service. Following is an example session. The + preceded lines are
Dovecot responses. Replace username and password with suitable
values in your case.

+OK Dovecot ready.
USER username
+OK
PASS password
+OK
QUIT
+OK Logging out.

If you get -ERR after typing the PASS line then you will need to
look deeper in to the dovecot logs.


 logs:
 mail.info log: http://pastebin.com/f6c486374
 mail.log: http://pastebin.com/f6e60f9b
 other logs are empty

 

 2.) When I want to send a message from a testuser to a testuser, with 
 Thunderbird, on the client, it just keeps asking for the password, when I 
 want click send. :S

 logs:
 mail.info: http://pastebin.com/f1bca774f
 mail.log: http://pastebin.com/f5c0be27c
 mail.warn: http://pastebin.com/f46806d2f

Try starting `saslauthd' with the -d flag for debugging the SASL failure.

 other logs are empty

 

 Info about the os  softwares [e.g.: dpkg -l | grep postfix]: 
 http://pastebin.com/f1d0cefd2

 192.168.56.4 is the client
 192.168.56.5 is the server
 [VirtualBox, Host-Only networking, they can ping each other]

 

 Later I want to use it with Squirrel Mail [plus spam filtering + antivirus], 
 but first, I just want to get it work :(

 Thank you for any help :S [_good_ docs, howtos, solution, or anything please! 
 :S :( ]


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



mestres em script... help !

2005-10-03 Thread Henrique Barcellos
seguinte galera...

tenhu um scrip muito simples... quase não da pra
chamar de script... é arquivo q executa o rdesktop,
porém... eu quero fazer o seguinte... :

quando o usuario clica ele executa o comando para
conectar o terminal server... só que eu quero q ele
fique executando o script enquanto estiver usando o
terminal server, para que quando o usuário desconectar
o script desligue o pc com um shutdown !!!

meu arquivo ta exatamente assim:

#!/bin/bash
rdesktop -f 192.168.200.100


como continuo ?

flw

henrique










___ 
Novo Yahoo! Messenger com voz: ligações, Yahoo! Avatars, novos emoticons e 
muito mais. Instale agora! 
www.yahoo.com.br/messenger/


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: mestres em script... help !

2005-10-03 Thread Jorge Alexandre
#!/bin/bash
rdesktop -f 192.168.200.100
shutdown -h now

On 10/3/05, Henrique Barcellos [EMAIL PROTECTED] wrote:
seguinte galera...tenhu um scrip muito simples... quase não da prachamar de script... é arquivo q executa o rdesktop,porém... eu quero fazer o seguinte... :quando o usuario clica ele executa o comando para
conectar o terminal server... só que eu quero q elefique executando o script enquanto estiver usando oterminal server, para que quando o usuário desconectaro script desligue o pc com um shutdown !!!
meu arquivo ta exatamente assim:#!/bin/bashrdesktop -f 192.168.200.100como continuo ?flwhenrique___
Novo Yahoo! Messenger com voz: ligações, Yahoo! Avatars, novos emoticons e muito mais. Instale agora!www.yahoo.com.br/messenger/--To UNSUBSCRIBE, email to 
[EMAIL PROTECTED]with a subject of unsubscribe. Trouble? Contact 
[EMAIL PROTECTED]


Re: mestres em script... help !

2005-10-03 Thread Fabiano Pires
Tem um comando que aguarda o fim de um determinado PID para continuar.
Acho que é o wait ou waitfor PID. Então ficaria mais ou menos assim:

#!/bin/bash
rdesktop -f 192.168.200.100
wait `pidof rdesktop`
shutdown -h now

Entendeu? O `pidof rdesktop` descobre o PID do rdesktop e o passa ao
wait, que fica aguardando o termino desse programa para dar
continuidade ao script.

Testa e dá um retorno.

Fabiano.
Em 03/10/05, Henrique Barcellos [EMAIL PROTECTED] escreveu:
seguinte galera...tenhu um scrip muito simples... quase não da prachamar de script... é arquivo q executa o rdesktop,porém... eu quero fazer o seguinte... :quando o usuario clica ele executa o comando para
conectar o terminal server... só que eu quero q elefique executando o script enquanto estiver usando oterminal server, para que quando o usuário desconectaro script desligue o pc com um shutdown !!!
meu arquivo ta exatamente assim:#!/bin/bashrdesktop -f 192.168.200.100como continuo ?flwhenrique___
Novo Yahoo! Messenger com voz: ligações, Yahoo! Avatars, novos emoticons e muito mais. Instale agora!www.yahoo.com.br/messenger/--To UNSUBSCRIBE, email to 
[EMAIL PROTECTED]with a subject of unsubscribe. Trouble? Contact 
[EMAIL PROTECTED]-- Abraços,Fabiano


Re: mestres em script... help !

2005-10-03 Thread Tiago Saboga
Desculpe Fabiano, apertei a tecla errada e a resposta foi só para você. Agora 
para lista

Em Seg 03 Out 2005 10:02, Fabiano Pires escreveu:
 Tem um comando que aguarda o fim de um determinado PID para continuar. Acho
 que é o wait ou waitfor PID. Então ficaria mais ou menos assim:

 #!/bin/bash
 rdesktop -f 192.168.200.100 http://192.168.200.100
 wait `pidof rdesktop`
 shutdown -h now

 Entendeu? O `pidof rdesktop` descobre o PID do rdesktop e o passa ao wait,
 que fica aguardando o termino desse programa para dar continuidade ao
 script.

Fiquei curioso. Pelo que eu achava, o bash executava cada linha e esperava o 
fim da execução para passar pela próxima linha. Assim, a linha wait seria 
desnecessária, pois a execução do script só continuaria quando o rdesktop 
fosse terminado - inclusive porque o script poderia continuar de forma 
diferente em função do código retornado pelo programa, por exemplo. Mas pela 
própria pergunta original, parece que não é assim que funciona. Mais 
detalhes?

tiago.



Re: mestres em script... help !

2005-10-03 Thread Gustavo Noronha Silva
Em Seg, 2005-10-03 às 10:17 -0300, Tiago Saboga escreveu:
 Fiquei curioso. Pelo que eu achava, o bash executava cada linha e esperava o 
 fim da execução para passar pela próxima linha. Assim, a linha wait seria 

Depende do programa... se o programa faz 'detach' do terminal e vai pra
background ele passa para a próxima linha sem esperar; mas normalmente
ele espera. O grande lance nesse caso é com que usuário o script vai
executar pra 1) não dar poderes desnecessários para o processo do
rdesktop e 2) ter poderes suficientes pra desligar o computador;

Eu acho que seria mais interessante conhecermos qual problema se está
tentando resolver pra propormos soluções mais adequadas.

Aparentemente a idéia é usar o GNU/Linux como simples frame pra o
rdesktop, de forma que não seja necessário comprar licenças de clientes
windows?

Abraço,

-- 
[EMAIL PROTECTED]: Gustavo Noronha http://people.debian.org/~kov
Debian:  http://www.debian.org  *  http://www.debian-br.org



signature.asc
Description: This is a digitally signed message part


Re: mestres em script... help !

2005-10-03 Thread Henrique Barcellos
isso mesmo... ! estou rodando linux em um pendrive...
fiz esse scriptzinhu para o usuario conseguir conectar
em um terminal server sem necessidade de
nconhecimentos em linux...

mas voltando ao assunto... sem o wait funcionou...
simplismente coloquei a linha (shutdown -h now) e ele
aguarda até q eu saia do rdesktop para desligar...

mas achei muuuito interessante esse wait.. até tentei
colocar ele no script porém me retornou um erro...:

-sh: wait: pid 8711 is not a child of this shell

não sei c tem haver com o shell, estou usando bash...
!

ja aproveitando tbm... como faço para esse script
inicializar automaticamente após carregar o kde !?

vlw

henrique


--- Gustavo Noronha Silva [EMAIL PROTECTED] escreveu:

 Em Seg, 2005-10-03 às 10:17 -0300, Tiago Saboga
 escreveu:
  Fiquei curioso. Pelo que eu achava, o bash
 executava cada linha e esperava o 
  fim da execução para passar pela próxima linha.
 Assim, a linha wait seria 
 
 Depende do programa... se o programa faz 'detach' do
 terminal e vai pra
 background ele passa para a próxima linha sem
 esperar; mas normalmente
 ele espera. O grande lance nesse caso é com que
 usuário o script vai
 executar pra 1) não dar poderes desnecessários para
 o processo do
 rdesktop e 2) ter poderes suficientes pra desligar o
 computador;
 
 Eu acho que seria mais interessante conhecermos qual
 problema se está
 tentando resolver pra propormos soluções mais
 adequadas.
 
 Aparentemente a idéia é usar o GNU/Linux como
 simples frame pra o
 rdesktop, de forma que não seja necessário comprar
 licenças de clientes
 windows?
 
 Abraço,
 
 -- 
 [EMAIL PROTECTED]: Gustavo Noronha
 http://people.debian.org/~kov
 Debian:  http://www.debian.org  * 
 http://www.debian-br.org
 
 








___ 
Novo Yahoo! Messenger com voz: ligações, Yahoo! Avatars, novos emoticons e 
muito mais. Instale agora! 
www.yahoo.com.br/messenger/


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



[Fwd: Re: [OT] Bash Script Help]

2005-05-24 Thread Fred L Youhanaie


Apologies Colin, the reply was meant to go to the list :-(

Fred L Youhanaie wrote:


Hi Colin,

Colin Ingram wrote:


Paul Smith wrote:

I was hoping to make this solution as simple as possible, so that my 
colleagues (most won't know perl or any other scripting language, but 
have experience with the shell) may use this code and be able to 
modify it easily to fit their needs. (They may or may not start with a 
file of the same format)



I have had to deal with this sort of things on quite a number of 
occasions, and I have my own little perl script, which is very similar 
to Paul's, mine came straight out of the perl cookbook ;-)


If you replace Paul's last print statement with:

print join('|', @fields), $/;

you will end up with a filter that produces a '|'-separated file, which 
can then be processed with shell/awk/cut etc., or whatever your users 
are comfortable with.


HTH

Cheers
f.




--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




Re: [OT] Bash Script Help

2005-05-24 Thread Colin Ingram

Almut Behrens wrote:

I assume I 
can make the first subexpression match zero or one time.  In that 
situation if the first subexpression doesn't match does $1=null?
   



...exactly (though it's 'undef', not null, strictly speaking).  And
the nice thing is that Perl doesn't segfault or throw fatal exceptions
in such cases...  it just works as expected.  If used in a numeric
context, an undefined value will just evaluate to 0, which is typically
what you want.

So, the above s/// statement simply has to be modified as follows

 s/^((\d+):)?(\d+):([\d.]+)/sprintf %.3f, $2*60**2 + $3*60 + $4/e

as you may have figured out yourself in the meantime.
 

yep I got it working just like this (w/o the '/sprintf %.3f' which I 
will add to ensure the precisions is explicit).  I like the way it 
works; thanks for the tip.  When I have free time later this summer I am 
going to learn some more about perl!



--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




Re: [OT] Bash Script Help

2005-05-24 Thread Colin Ingram

Fred L Youhanaie wrote:



Hi Colin,

I have had to deal with this sort of things on quite a number of 
occasions, and I have my own little perl script, which is very similar 
to Paul's, mine came straight out of the perl cookbook ;-)


If you replace Paul's last print statement with:

print join('|', @fields), $/;

you will end up with a filter that produces a '|'-separated file, 
which can then be processed with shell/awk/cut etc., or whatever your 
users are comfortable with.


I'll have to look into this some more when I have time.  A script like 
this could be very useful for preparing the formated output from the 
program in question.  Everyone could just run their data through this 
script and then modify some awk commands to get the fields of their 
choice.  Thanks Fred and Paul for the suggestions.





--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




[OT] Bash Script Help

2005-05-23 Thread Colin Ingram
This is not a debian specific question but I thought some of you could 
help.  I am writing a shell script to parse a CSV file to prepare it for 
input into a program which will fit the data by a non-linear least 
squares fitting routine.  This program takes input from a file 
containing two columns for X and Y data.


the CSV file looks like this:
Calibrations:
X:, 0.0645, Y:, 0.0645, Units:, um, Gray Units:, 
Image Name, Image Plane, Elapsed Time, Area, Integrated Intensity
2005.05.16 - FRAPtest1.6, 1, 00:00.000, 774.838, 3.24557e+007
2005.05.16 - FRAPtest1.6, 2, 00:02.510, 774.838, 3.23482e+007
2005.05.16 - FRAPtest1.6, 3, 00:05.007, 774.838, 3.24578e+007
2005.05.16 - FRAPtest1.6, 4, 00:07.507, 774.838, 2.77091e+007
2005.05.16 - FRAPtest1.6, 5, 00:10.006, 774.838, 2.80516e+007
2005.05.16 - FRAPtest1.6, 6, 00:12.507, 774.838, 2.82355e+007
2005.05.16 - FRAPtest1.6, 7, 00:15.006, 774.838, 2.84682e+007
2005.05.16 - FRAPtest1.6, 8, 00:17.506, 774.838, 2.86124e+007
2005.05.16 - FRAPtest1.6, 9, 00:20.006, 774.838, 2.87942e+007
2005.05.16 - FRAPtest1.6, 10, 00:22.507, 774.838, 2.89613e+007
2005.05.16 - FRAPtest1.6, 11, 00:25.006, 774.838, 2.91049e+007
2005.05.16 - FRAPtest1.6, 12, 00:27.506, 774.838, 2.9186e+007
2005.05.16 - FRAPtest1.6, 13, 00:30.007, 774.838, 2.93118e+007
2005.05.16 - FRAPtest1.6, 14, 00:32.507, 774.838, 2.94214e+007
2005.05.16 - FRAPtest1.6, 15, 00:35.007, 774.838, 2.94967e+007
2005.05.16 - FRAPtest1.6, 16, 00:37.507, 774.838, 2.96811e+007
---snip---

my script so far:
#!/bin/bash
tempfile=/dev/shm/frapfitter.$$
for INPUTFILE in $@
do
  # grab the info we need for frapfitter (filename and region areas)
  filename=$(awk -F '' 'NR==4 {print $2}' $INPUTFILE)
  sigarea=$(awk -F ,  'NR==4 {print $4}' $INPUTFILE)
  bgarea=$(awk -F ,  'NR==54 {print $4}' $INPUTFILE)

  # Parse the Metamorph output file and create an inputfile for
  # frapfitter
  {
  # remove calibration header
  sed -e '1,3d' $INPUTFILE |

  # grab time and integrated intensity columns
  cut -d , -s -f 3,5 |

  # remove quotations, leading and trailing space, and ensure unix
  # format
  sed -e 's///g;s/^[ ^t]*//;s/[ ^t]*$//;' |
  dos2unix
  }  $tempfile
done

rm $tempfile

this creates a file that looks like this:
00:00.000, 3.24557e+007
00:02.510, 3.23482e+007
00:05.007, 3.24578e+007
00:07.507, 2.77091e+007
00:10.006, 2.80516e+007
00:12.507, 2.82355e+007
00:15.006, 2.84682e+007
00:17.506, 2.86124e+007
00:20.006, 2.87942e+007
00:22.507, 2.89613e+007
00:25.006, 2.91049e+007
00:27.506, 2.9186e+007
00:30.007, 2.93118e+007
00:32.507, 2.94214e+007
00:35.007, 2.94967e+007
00:37.507, 2.96811e+007
---snip---

I now need to covert the elapse time column from the string format 
hours:min:sec to a column containing just seconds.  I am unsure how to 
do this.  Can I use command substitution in a sed substitute command? 
(sed -e 's//$(command to do math)/')  I don't necessarily need a piece 
of code but if someone could recommend a bash tool which is well suited 
for this task or outline some steps, I can probably get to my solution. 
 Thanks in advance.



--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




Re: [OT] Bash Script Help

2005-05-23 Thread Almut Behrens
On Mon, May 23, 2005 at 04:17:44PM -0500, Colin Ingram wrote:
 (...)
 
 this creates a file that looks like this:
 00:00.000, 3.24557e+007
 00:02.510, 3.23482e+007
 00:05.007, 3.24578e+007
 00:07.507, 2.77091e+007
 ---snip---
 
 I now need to covert the elapse time column from the string format 
 hours:min:sec to a column containing just seconds.  I am unsure how to 
 do this.  Can I use command substitution in a sed substitute command?

You could pipe the output of your script through the following perl
command:

  ... | perl -pe 's/^(\d+):(\d+):(\d+)/$1*60**2 + $2*60 + $3/e'

in case the time string represents hours:min:sec.
If it's min:sec.msec (looks like it to me...), then it'd be

  ... | perl -pe 's/^(\d+):([\d.]+)/$1*60 + $2/e'

The s///e option requests command subtitution, where the value can be
any perl code, the result of which will be the replacement string.

I'm not saying it cannot be done in sed, I just don't know how -- from
the top of my head.  And it'd probably not be easier... :)

Almut


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: [OT] Bash Script Help

2005-05-23 Thread Marty

Colin Ingram wrote:
This is not a debian specific question but I thought some of you could 
help.  I am writing a shell script to parse a CSV file to prepare it for 
input into a program which will fit the data by a non-linear least 
squares fitting routine.  This program takes input from a file 
containing two columns for X and Y data.


the CSV file looks like this:
Calibrations:
X:, 0.0645, Y:, 0.0645, Units:, um, Gray Units:, 
Image Name, Image Plane, Elapsed Time, Area, Integrated Intensity
2005.05.16 - FRAPtest1.6, 1, 00:00.000, 774.838, 3.24557e+007
2005.05.16 - FRAPtest1.6, 2, 00:02.510, 774.838, 3.23482e+007
2005.05.16 - FRAPtest1.6, 3, 00:05.007, 774.838, 3.24578e+007
2005.05.16 - FRAPtest1.6, 4, 00:07.507, 774.838, 2.77091e+007
2005.05.16 - FRAPtest1.6, 5, 00:10.006, 774.838, 2.80516e+007
2005.05.16 - FRAPtest1.6, 6, 00:12.507, 774.838, 2.82355e+007
2005.05.16 - FRAPtest1.6, 7, 00:15.006, 774.838, 2.84682e+007
2005.05.16 - FRAPtest1.6, 8, 00:17.506, 774.838, 2.86124e+007
2005.05.16 - FRAPtest1.6, 9, 00:20.006, 774.838, 2.87942e+007
2005.05.16 - FRAPtest1.6, 10, 00:22.507, 774.838, 2.89613e+007
2005.05.16 - FRAPtest1.6, 11, 00:25.006, 774.838, 2.91049e+007
2005.05.16 - FRAPtest1.6, 12, 00:27.506, 774.838, 2.9186e+007
2005.05.16 - FRAPtest1.6, 13, 00:30.007, 774.838, 2.93118e+007
2005.05.16 - FRAPtest1.6, 14, 00:32.507, 774.838, 2.94214e+007
2005.05.16 - FRAPtest1.6, 15, 00:35.007, 774.838, 2.94967e+007
2005.05.16 - FRAPtest1.6, 16, 00:37.507, 774.838, 2.96811e+007
---snip---

my script so far:
#!/bin/bash
tempfile=/dev/shm/frapfitter.$$
for INPUTFILE in $@
do
   # grab the info we need for frapfitter (filename and region areas)
   filename=$(awk -F '' 'NR==4 {print $2}' $INPUTFILE)
   sigarea=$(awk -F ,  'NR==4 {print $4}' $INPUTFILE)
   bgarea=$(awk -F ,  'NR==54 {print $4}' $INPUTFILE)

   # Parse the Metamorph output file and create an inputfile for
   # frapfitter
   {
   # remove calibration header
   sed -e '1,3d' $INPUTFILE |

   # grab time and integrated intensity columns
   cut -d , -s -f 3,5 |

   # remove quotations, leading and trailing space, and ensure unix
   # format
   sed -e 's///g;s/^[ ^t]*//;s/[ ^t]*$//;' |
   dos2unix
   }  $tempfile
done

rm $tempfile

this creates a file that looks like this:
00:00.000, 3.24557e+007
00:02.510, 3.23482e+007
00:05.007, 3.24578e+007
00:07.507, 2.77091e+007
00:10.006, 2.80516e+007
00:12.507, 2.82355e+007
00:15.006, 2.84682e+007
00:17.506, 2.86124e+007
00:20.006, 2.87942e+007
00:22.507, 2.89613e+007
00:25.006, 2.91049e+007
00:27.506, 2.9186e+007
00:30.007, 2.93118e+007
00:32.507, 2.94214e+007
00:35.007, 2.94967e+007
00:37.507, 2.96811e+007
---snip---

I now need to covert the elapse time column from the string format 
hours:min:sec to a column containing just seconds.  I am unsure how to 
do this.  Can I use command substitution in a sed substitute command? 
(sed -e 's//$(command to do math)/')  I don't necessarily need a piece 
of code but if someone could recommend a bash tool which is well suited 
for this task or outline some steps, I can probably get to my solution. 
  Thanks in advance.





Too bad you don't have a two digit second format, or you could do the following:

HMS='12:34:56'
SECONDS=`date -ud '1/1/70 '$HMS +%s`



--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




Re: [OT] Bash Script Help

2005-05-23 Thread Paul Smith
%% Colin Ingram [EMAIL PROTECTED] writes:

  ci This is not a debian specific question but I thought some of you
  ci could help.  I am writing a shell script to parse a CSV file

Why would you choose bash to do this?  The shell is great for running
commands, but it's really poor at parsing text, compared to
alternatives.  The most obvious is Perl, and you can even:

  # apt-get install libtext-csv-perl

to install a Perl module that will parse CSV _for_ you, managing all the
quoting, escaping, etc.

Here's a sample program (note your CSV example is not a valid file: in a
real CSV file you can't have whitespace after commas like that; I added
a stupid line to fix this but it breaks things if you have ,  in any
quoted field).


---
#!/usr/bin/perl

use Text::CSV;

my $csv = Text::CSV_XS-new();

open(CSV, $ARGV[0]) or die open: $ARGV[0]: $!\n;

while (defined ($_ = CSV)) {
  # Valid CSV cannot have whitespace after commas--note this breaks if
  # you have ,  inside a string... fix your CSV and remove this line!
  s/, /,/;

  $csv-parse($_) or warn(invalid CSV line: , $csv-error_input(), \n), 
next;
  my @fields = $csv-fields();

  # Do something with the array... access it as $fields[0] ... $fields[n]
  print Fields: (@fields)\n;
}

close(CSV) or die close: $ARGV[0]: $!\n;


-- 
---
 Paul D. Smith [EMAIL PROTECTED]   HASMAT--HA Software Mthds  Tools
 Please remain calm...I may be mad, but I am a professional. --Mad Scientist
---
   These are my opinions---Nortel Networks takes no responsibility for them.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: [OT] Bash Script Help

2005-05-23 Thread Colin Ingram

Paul Smith wrote:


%% Colin Ingram [EMAIL PROTECTED] writes:

 ci This is not a debian specific question but I thought some of you
 ci could help.  I am writing a shell script to parse a CSV file

Why would you choose bash to do this?  The shell is great for running
commands, but it's really poor at parsing text, compared to
alternatives.  

I was hoping to make this solution as simple as possible, so that my 
colleagues (most won't know perl or any other scripting language, but 
have experience with the shell) may use this code and be able to modify 
it easily to fit their needs. (They may or may not start with a file of 
the same format)



The most obvious is Perl, and you can even:

 # apt-get install libtext-csv-perl

to install a Perl module that will parse CSV _for_ you, managing all the
quoting, escaping, etc.
 

I'll check this out.  I guess I can always be available for others in 
case they need help with their modifications. 


Here's a sample program (note your CSV example is not a valid file: in a
real CSV file you can't have whitespace after commas like that; 

I realize that but I can't change the file...our crappy, proprietary 
image processing software generates in that way.  Needless to say, the 
software has little documentation and is poorly support; I have know 
idea how to customize the output. (I also have little say in using an 
alternative program, although I'm working hard on convincing the boss 
that change is needed)



I added
a stupid line to fix this but it breaks things if you have ,  in any
quoted field).


---
#!/usr/bin/perl

use Text::CSV;

my $csv = Text::CSV_XS-new();

open(CSV, $ARGV[0]) or die open: $ARGV[0]: $!\n;

while (defined ($_ = CSV)) {
 # Valid CSV cannot have whitespace after commas--note this breaks if
 # you have ,  inside a string... fix your CSV and remove this line!
 s/, /,/;

 $csv-parse($_) or warn(invalid CSV line: , $csv-error_input(), \n), next;
 my @fields = $csv-fields();

 # Do something with the array... access it as $fields[0] ... $fields[n]
 print Fields: (@fields)\n;
}

close(CSV) or die close: $ARGV[0]: $!\n;


 




--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




Re: [OT] Bash Script Help

2005-05-23 Thread Colin Ingram

Almut Behrens wrote:


On Mon, May 23, 2005 at 04:17:44PM -0500, Colin Ingram wrote:
 


(...)

this creates a file that looks like this:
00:00.000, 3.24557e+007
00:02.510, 3.23482e+007
00:05.007, 3.24578e+007
00:07.507, 2.77091e+007
---snip---

I now need to covert the elapse time column from the string format 
hours:min:sec to a column containing just seconds.  I am unsure how to 
do this.  Can I use command substitution in a sed substitute command?
   



You could pipe the output of your script through the following perl
command:

 ... | perl -pe 's/^(\d+):(\d+):(\d+)/$1*60**2 + $2*60 + $3/e'

in case the time string represents hours:min:sec.
If it's min:sec.msec (looks like it to me...), then it'd be

 

its actually [hours]:min:sec (the secs have ms precision).  I assume I 
can make the first subexpression match zero or one time.  In that 
situation if the first subexpression doesn't match does $1=null?



 ... | perl -pe 's/^(\d+):([\d.]+)/$1*60 + $2/e'

The s///e option requests command subtitution, where the value can be
any perl code, the result of which will be the replacement string.
 


I'll look into this some more.  Thanks for the suggestion


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




Re: [OT] Bash Script Help

2005-05-23 Thread Almut Behrens
On Mon, May 23, 2005 at 09:50:12PM -0500, Colin Ingram wrote:
 Almut Behrens wrote:
 
  ... | perl -pe 's/^(\d+):(\d+):(\d+)/$1*60**2 + $2*60 + $3/e'
 
 in case the time string represents hours:min:sec.
 If it's min:sec.msec (looks like it to me...), then it'd be
  
 
 its actually [hours]:min:sec (the secs have ms precision).

ah, I see.

 I assume I 
 can make the first subexpression match zero or one time.  In that 
 situation if the first subexpression doesn't match does $1=null?

...exactly (though it's 'undef', not null, strictly speaking).  And
the nice thing is that Perl doesn't segfault or throw fatal exceptions
in such cases...  it just works as expected.  If used in a numeric
context, an undefined value will just evaluate to 0, which is typically
what you want.

So, the above s/// statement simply has to be modified as follows

  s/^((\d+):)?(\d+):([\d.]+)/sprintf %.3f, $2*60**2 + $3*60 + $4/e

as you may have figured out yourself in the meantime.

Or, taking advantage of the fact that any trailing garbage (':') does
not do any harm to string-to-number conversions in Perl, you can even
save one pair of parentheses ;) -- not universally recommended, though.

  s/^(\d+:)?(\d+):([\d.]+)/sprintf %.3f, $1*60**2 + $2*60 + $3/e

(Alternatively, you could of course also write

  perl -pe '{} while s/^(\d+):([\d.]+)/$1*60+$2/e'

as another step to achieving obfuscation.  OK, I'm being silly.)

Almut


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



script help

2004-12-29 Thread Bob Alexander
I keep a few different kernel source trees under /usr/src and each of 
them has a different .config file.

Part of my pre-backup script I would like to run a command such as
find /usr/src -name .config
for example:
/usr/src/kernel-source-2.6.9-rja/.config
/usr/src/linux-2.6.10-rja/.config
and for every match write a file to my /backup_data directory with a 
filename that is made up like kernel-source-2.6.9-rja.config and 
linux-2.6.10-rja.config or some similar unique filename which relates 
the the kernel tree.

Thank you for any help,
Bob
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: script help

2004-12-29 Thread Joris Huizer
Bob Alexander wrote:
I keep a few different kernel source trees under /usr/src and each of 
them has a different .config file.

Part of my pre-backup script I would like to run a command such as
find /usr/src -name .config
for example:
/usr/src/kernel-source-2.6.9-rja/.config
/usr/src/linux-2.6.10-rja/.config
and for every match write a file to my /backup_data directory with a 
filename that is made up like kernel-source-2.6.9-rja.config and 
linux-2.6.10-rja.config or some similar unique filename which relates 
the the kernel tree.

Thank you for any help,
Bob

(using bash:)
for i in *
do
  if [ -d $i ]
  then
if [ -f $i/.config ]
  then
  echo cp $i/.config /backup_data/$i.config
fi
  fi
done
If this prints the correct lines, remove echo in front of the cp and run 
again ;)

HTH,
Joris
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: script help

2004-12-29 Thread Darryl Clarke
On Wed, 29 Dec 2004 15:26:17 +0100, Bob Alexander [EMAIL PROTECTED] wrote:
 I keep a few different kernel source trees under /usr/src and each of
 them has a different .config file.
 
 Part of my pre-backup script I would like to run a command such as
 
 find /usr/src -name .config
 
 for example:
 
 /usr/src/kernel-source-2.6.9-rja/.config
 /usr/src/linux-2.6.10-rja/.config
 
 and for every match write a file to my /backup_data directory with a
 filename that is made up like kernel-source-2.6.9-rja.config and
 linux-2.6.10-rja.config or some similar unique filename which relates
 the the kernel tree.

With 'find' you can -exec on each result.

For example (note the trailing \; is required to end the exec string.
find will execute all commands until that is found.):

find /usr/src -name .config -exec cp {} /backup_data{} \;

{}  will be expanded to the entire path of the found file. The above
line won't work because cp won't create the entire path
/backup_data/usr/src/kernel-source-2.6.9-rja/.config :) You might
want to process {} to create a proper destination.

Hope that Helps!


-- 
Darryl
[EMAIL PROTECTED]
http://smartssa.com / http://darrylclarke.com


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



(solved) Re: Could you give an example iptables script? (Help... I want to learn this stuff)

2004-01-01 Thread Joris Huizer
[EMAIL PROTECTED] wrote:
Quoting Joris Huizer [EMAIL PROTECTED]:

BTW, if something weird happens, how can I shut it down again? (you 
never know...)


iptables -F
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -t nat -F
ought to do it.  This won't clear out user-defined changes, but without any
rules to jump into them, it won't matter (if your primary objective is just to
get up and running).
mickey


Thanks mickey :-)

I just put the iptables script in place after making a backup of the 
older script, and internet functions normally (also after a reboot) at 
least as far as I can tell

Thanks for all the help,

Happy New Year,

Joris

--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: Could you give an example iptables script? (Help... I want to learn this stuff)

2004-01-01 Thread Jan Minar
On Tue, Dec 30, 2003 at 01:57:21PM -0700, [EMAIL PROTECTED] wrote:
 Quoting Joris Huizer [EMAIL PROTECTED]:
  BTW, if something weird happens, how can I shut it down again? (you 
  never know...)

I just wanted to recommend /etc/init.d/iptables, and looked into the
script, but...  It contains outright security issues; don't use it.  The
iptables docs say it's not very useful, but that's a really soft
description.  Bugreport pending.

 iptables -F
 iptables -P INPUT ACCEPT
 iptables -P FORWARD ACCEPT
 iptables -P OUTPUT ACCEPT
 iptables -t nat -F
 
 ought to do it.  This won't clear out user-defined changes, but without any

It will. -F will flush everything but the policy, the -P will set the
policy.  The result will be the same as the bootup default.

Jan.

-- 
Jan Minar  Please don't CC me, I'm subscribed. x 4


pgp0.pgp
Description: PGP signature


Re: Could you give an example iptables script? (Help... I want to learn this stuff)

2003-12-30 Thread Joris Huizer
Shaun Crossley wrote:
On Wed, Dec 24, 2003 at 10:06:25AM +0100, Joris Huizer wrote:

Hello everybody,

I'm planning to use iptables as it seems it's powerfull and it will let 
me choose really what is allowed and what is not (because of p2p stuff 
etc. which allways keeps complaining - and out of curiosity)

However, I never used iptables before and it looks like it's got some 
learning curve :-P I found a great tutorial at 
http://iptables-tutorial.frozentux.net/iptables-tutorial.html ..
I'm not going to try myself just like that as I'm afraid I might kill 
the internet connection like that, therefor I want to ask for some help.


I recently ran across the Easy Firewall Generator for IPTables
web page, where you can plug in some simple requirements and it
will generate an iptables firewall script on the fly.  Check it
out at:
	http://easyfwgen.morizot.net/


Thank you for your reply,

I found that one easy to use and I just checked for the needed modules 
in the kernel (they are there allright)
I'll try the resulting script soon!
BTW, if something weird happens, how can I shut it down again? (you 
never know...)

Thanks again ,

Joris

--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: Could you give an example iptables script? (Help... I want to learn this stuff)

2003-12-30 Thread mickey
Quoting Joris Huizer [EMAIL PROTECTED]:
 BTW, if something weird happens, how can I shut it down again? (you 
 never know...)

iptables -F
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -t nat -F

ought to do it.  This won't clear out user-defined changes, but without any
rules to jump into them, it won't matter (if your primary objective is just to
get up and running).

mickey


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Could you give an example iptables script? (Help... I want to learn this stuff)

2003-12-24 Thread Joris Huizer
Hello everybody,

I'm planning to use iptables as it seems it's powerfull and it will let 
me choose really what is allowed and what is not (because of p2p stuff 
etc. which allways keeps complaining - and out of curiosity)

However, I never used iptables before and it looks like it's got some 
learning curve :-P I found a great tutorial at 
http://iptables-tutorial.frozentux.net/iptables-tutorial.html ..
I'm not going to try myself just like that as I'm afraid I might kill 
the internet connection like that, therefor I want to ask for some help.

These are the details:
I am connecting to the net by dhcp, with an assigned (dynamic) IP 
address. I want to be able to...
- surf the web
- email (using smtp-server to send, pop-server to receive)
- use ftp for uploads/downloads
- use ssh, only outgoing, I don't need to access this computer by ssh
- I sometimes use a chat prog called amsn
Did I forget something basic ?

If the script allready covers those... great! Then I'll just install and 
read through the entire doc afterwards... otherwise, can you post the 
lines I have to add?

I hope someone is so kind to post an example. I can't yet read the dhcp 
script to the details of what is accepted and what not, so...

Thanks for any help!
Merry Christmas :-)
Joris Huizer

--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: Could you give an example iptables script? (Help... I want to learn this stuff)

2003-12-24 Thread Anthony Campbell
On 24 Dec 2003, Joris Huizer wrote:
 Hello everybody,
 
 I'm planning to use iptables as it seems it's powerfull and it will let
 me choose really what is allowed and what is not (because of p2p stuff
 etc. which allways keeps complaining - and out of curiosity)
 
 However, I never used iptables before and it looks like it's got some
 learning curve :-P I found a great tutorial at
 http://iptables-tutorial.frozentux.net/iptables-tutorial.html ..
 I'm not going to try myself just like that as I'm afraid I might kill
 the internet connection like that, therefor I want to ask for some help.
 
 These are the details:
 I am connecting to the net by dhcp, with an assigned (dynamic) IP
 address. I want to be able to...
 - surf the web
 - email (using smtp-server to send, pop-server to receive)
 - use ftp for uploads/downloads
 - use ssh, only outgoing, I don't need to access this computer by ssh
 - I sometimes use a chat prog called amsn
 Did I forget something basic ?
 
 If the script allready covers those... great! Then I'll just install and
 read through the entire doc afterwards... otherwise, can you post the
 lines I have to add?
 
 I hope someone is so kind to post an example. I can't yet read the dhcp
 script to the details of what is accepted and what not, so...
 
 Thanks for any help!
 Merry Christmas :-)
 
 Joris Huizer


I was in the same state as you recently, having just installed ADSL. If,
like me, you knew nothing about iptables to start with, I'd suggest
starting with one of the set-up apps (available in deb form). The best
two I've found are firestarter and shorewall. Firestarter is extremely
easy to set up, via a wizard; shorewall is also easy to set up if you go
to the website at http://www.shorewall.net for the guide. IMO this is
one of the best sites of its kind that I've seen.

Of the above two, I'd say go for shorewall, if only because it has a
useful guide to choosing which modules to enable in the kernel. It also
has a fairly active mailing list.

A.
-- 
[EMAIL PROTECTED]||  http://www.acampbell.org.uk
using Linux GNU/Debian ||  for book reviews, electronic 
Windows-free zone  ||  books and skeptical articles


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: Could you give an example iptables script? (Help... I want to learn this stuff)

2003-12-24 Thread Shaun Crossley
On Wed, Dec 24, 2003 at 10:06:25AM +0100, Joris Huizer wrote:
 Hello everybody,
 
 I'm planning to use iptables as it seems it's powerfull and it will let 
 me choose really what is allowed and what is not (because of p2p stuff 
 etc. which allways keeps complaining - and out of curiosity)
 
 However, I never used iptables before and it looks like it's got some 
 learning curve :-P I found a great tutorial at 
 http://iptables-tutorial.frozentux.net/iptables-tutorial.html ..
 I'm not going to try myself just like that as I'm afraid I might kill 
 the internet connection like that, therefor I want to ask for some help.

I recently ran across the Easy Firewall Generator for IPTables
web page, where you can plug in some simple requirements and it
will generate an iptables firewall script on the fly.  Check it
out at:

http://easyfwgen.morizot.net/


-- 

Shaun Crossley
mailto:[EMAIL PROTECTED]
http://www.whatever.ca


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



IPtables and DMZ script help

2003-10-18 Thread Steve
Hi there guys is there any one that can help me on IPtables and DMZ.
Perferably have a pre made script that I can mod to suit my needs..
This is what I need to do.

External Network (BAD)

 |
 |
  eth1 | ppp0
   ---
   | 200.62.161.110 |
200.62.181.222 (network)
   |   |  eth2
200.62.181.229 (broadcast)
   |
|--
   |   |  200.62.181.223  |
||
   |   |
|  ||
   | 10.1.1.1 | |
||
   ---  
   -- - 
| eth0   | WEB+mail
|   | WEB2+sql |  |  web3  |

 -- 
-
|200.62.181.224
200.62.181.225 200.62.181.226
|
  Internal Network (GOOD)
Network:  10.1.1.0
Broadcast Address 10.1.1.127



One card is terminated with the external leased line. (eth1).
One card is connected to my hub/1 which caters to the private lan. (eth0).
The last card is connected to my hub/2 takes care of my dmzone (eth2).


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: IPtables and DMZ script help

2003-10-18 Thread Mehmet AK



hi steve 

you have to configure dhcpd.conf file . 

write these are commands in 
/etc/rc.local file 


ifconfig eth0 down
ifconfig eth1 down
ifconfig eth0 10.1.1.1 

ifconfig eth1 
200.62.161.110
ifconfig eth0 up
ifconfig eth1 up
route del default gw
route add default gw 200.62.161.110 

iptables -t nat -I POSTROUTING -o eth1 -j 
MASQUERADE
if you are using squid proxy 

iptables -t nat -A PREROUTING -i eth0 -p 
tcp --dport 80 -j REDIRECT --to-port 3128


- Original Message - 
From: "Steve" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, October 19, 2003 5:28 AM
Subject: IPtables and DMZ script 
help
 Hi there guys is there any one that can help me on IPtables and 
DMZ. Perferably have a pre made script that I can mod to suit my 
needs.. This is what I need to do.  External Network 
(BAD)  
 
| 
 
| 
 
eth1 | ppp0  
--- 
 | 200.62.161.110 
| 200.62.181.222 (network) 
 
| 
| eth2 200.62.181.229 (broadcast) 
 | 
|-- 
 
| 
| 200.62.181.223 
| 
| 
|  
| 
| 
| 
| 
|  
| 
10.1.1.1 
| 
| 
| 
|  
--- 
  
 
-- 
-  
 
| 
eth0 
| WEB+mail | 
| WEB2+sql 
| 
| web3 |  
 
 
-- 
 - 
 
| 
200.62.181.224 
200.62.181.225 
200.62.181.226 
 
|  Internal 
Network (GOOD) Network: 10.1.1.0 Broadcast Address 
10.1.1.127One card is terminated with the 
external leased line. (eth1). One card is connected to my hub/1 which 
caters to the private lan. (eth0). The last card is connected to my 
hub/2 takes care of my dmzone (eth2).   --  To 
UNSUBSCRIBE, email to [EMAIL PROTECTED] 
 with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED] 



Re: Script help

2003-09-07 Thread Jeff Elkins
On Sunday 07 September 2003 1:10 am, Dave Carrigan wrote:
On Sat, Sep 06, 2003 at 10:03:09PM -0400, Jeff Elkins wrote:
 I'm doing a lot of work with a Sharp Zaurus which requires several
 re-flashes of the box daily - With my initrd.bin, ssh keys on the Z
 regenerate with each flash. As a consequence, my host .ssh/known_hosts is
 frequently outdated and I must edit it to remove references to
 z,xxx.xxx.xxx.xxx.

 I'd like to gen up a script to nuke references in .ssh/known_hosts to the
 Zaurus. It's trivial to edit known_hosts, but I'd like to eliminate this
 step.

perl -ni.bak -e 'print unless /^z,xxx.xxx.xxx.xxx/' ~/.ssh/known_hosts

Thanks, Karsten and Dave.

Jeff


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Script help

2003-09-06 Thread Jeff Elkins
I'm doing a lot of work with a Sharp Zaurus which requires several re-flashes  
of the box daily - With my initrd.bin, ssh keys on the Z regenerate with each 
flash. As a consequence, my host .ssh/known_hosts is frequently outdated and 
I must edit it to remove references to z,xxx.xxx.xxx.xxx.

I'd like to gen up a script to nuke references in .ssh/known_hosts to the 
Zaurus. It's trivial to edit known_hosts, but I'd like to eliminate this 
step.

Can someone point me in the right direction? 

TIA

Jeff Elkins




-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: Script help

2003-09-06 Thread Karsten M. Self
on Sat, Sep 06, 2003 at 10:03:09PM -0400, Jeff Elkins ([EMAIL PROTECTED]) wrote:
 I'm doing a lot of work with a Sharp Zaurus which requires several
 re-flashes  of the box daily - With my initrd.bin, ssh keys on the Z
 regenerate with each flash. As a consequence, my host .ssh/known_hosts
 is frequently outdated and I must edit it to remove references to
 z,xxx.xxx.xxx.xxx.
 
 I'd like to gen up a script to nuke references in .ssh/known_hosts to the 
 Zaurus. It's trivial to edit known_hosts, but I'd like to eliminate this 
 step.
 
 Can someone point me in the right direction? 

sed -e '/pattern/d'  ~/.ssh/known_hosts  ~/.ssh/known_hosts.tmp 
mv ~/.ssh/known_hosts.tmp ~/.ssh/known_hosts

If you have known good state of known_hosts that you want to restore,
just copy it in from a template at startup or login.

Peace.

-- 
Karsten M. Self [EMAIL PROTECTED]http://kmself.home.netcom.com/
 What Part of Gestalt don't you understand?
Defeat EU Software Patents! http://swpat.ffii.org/


pgp0.pgp
Description: PGP signature


Re: Script help

2003-09-06 Thread Dave Carrigan
On Sat, Sep 06, 2003 at 10:03:09PM -0400, Jeff Elkins wrote:

 I'm doing a lot of work with a Sharp Zaurus which requires several re-flashes  
 of the box daily - With my initrd.bin, ssh keys on the Z regenerate with each 
 flash. As a consequence, my host .ssh/known_hosts is frequently outdated and 
 I must edit it to remove references to z,xxx.xxx.xxx.xxx.
 
 I'd like to gen up a script to nuke references in .ssh/known_hosts to the 
 Zaurus. It's trivial to edit known_hosts, but I'd like to eliminate this 
 step.

perl -ni.bak -e 'print unless /^z,xxx.xxx.xxx.xxx/' ~/.ssh/known_hosts

-- 
Dave Carrigan
Seattle, WA, USA
[EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680
UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL


pgp0.pgp
Description: PGP signature


Re: script help

2000-11-09 Thread Erik Steffl
  man find

erik

Chris Mason wrote:
 
 I need to come up with a bash shell script that deletes all the files in a
 folder older than N days. I'm not sure how to test for file age so I can't
 get it done myself, can someone suggest a way?
 
 Chris Mason
 Box 340, The Valley, Anguilla, British West Indies
 Tel: 264 497 5670 Fax: 264 497 8463
 USA Fax (561) 382-7771
 Take a virtual tour of the island
 http://net.ai/ The Anguilla Guide
 Find out more about NetConcepts
 www.netconcepts.ai
 Talk to me in real time with Instant Messenger: [EMAIL PROTECTED]
 
 --
 Unsubscribe?  mail -s unsubscribe [EMAIL PROTECTED]  /dev/null



script help

2000-11-07 Thread Chris Mason
I need to come up with a bash shell script that deletes all the files in a
folder older than N days. I'm not sure how to test for file age so I can't
get it done myself, can someone suggest a way?

Chris Mason
Box 340, The Valley, Anguilla, British West Indies
Tel: 264 497 5670 Fax: 264 497 8463
USA Fax (561) 382-7771
Take a virtual tour of the island
http://net.ai/ The Anguilla Guide
Find out more about NetConcepts
www.netconcepts.ai
Talk to me in real time with Instant Messenger: [EMAIL PROTECTED]




Re: script help

2000-11-07 Thread Mike Quin
 Chris Mason [EMAIL PROTECTED] writes:

 I need to come up with a bash shell script that deletes all the files in a
 folder older than N days. I'm not sure how to test for file age so I can't
 get it done myself, can someone suggest a way?

use find(1) with the mtime flag, e.g.

find /tmp -type f -mtime +30 -exec rm {} \;

will remove all files in /tmp that are more than 30 days old.

-- 
Mike Quin
Unix Systems Support
Systems and Networks Group, University of Stirling
Clue. You've either got it, or you work for UUnet - seen on UKMM



Script help...............

1998-10-27 Thread Phillip Neumann
Hi debian world...




Im not know very much about scripts so i need some help with one..

Here my situation:

A script will be executed when i call to my linux box... here it is: 

/etc/init.d/xringd stop
/root/IP_MAIL
pon incomingcall
/etc/init.d/xringd start|
|
|

This has the -detach option so i can kill it 
and the script will continue...



Now, i have problems with /root/IP_MAIL, becouse it try to send me my ip number 
before i can get one... this is how IP_mail looks:

1)DAY=$(date +%A)
2)NUMBER=$(date +%d)
3)TIME=$(date +%r)
4)MONTH=$(date +%m)
5)IP=$(/sbin/ifconfig | grep inet | awk '{print $2}' |awk -F: '{print $2}' | 
grep -v 127)
6)echo Today, $DAY   $NUMBER/$MONTH  [$TIME] you have got an ip address: $IP 
 /tmp/iptemporal.tmp
7)mail -s Identidad: $IP [EMAIL PROTECTED]  /tmp/iptemporal.tmp


in [EMAIL PROTECTED] i get:
Today, Monday   26/10  [07:45:12 PM] you have got an ip address:


so how can i make IP_MAIL do 1,2,3,4 and 5 until $IP is not empty ?? (is $IP is 
not empty then go on and send the mail...)



Thanks,
Phillip Neumann
[EMAIL PROTECTED]


Re: Script help...............

1998-10-27 Thread Michael Beattie
On Mon, 26 Oct 1998, Phillip Neumann wrote:

 Hi debian world...
 
 
 
 
 Im not know very much about scripts so i need some help with one..
 
 Here my situation:
 
 A script will be executed when i call to my linux box... here it is: 
 
 /etc/init.d/xringd stop
 /root/IP_MAIL
 pon incomingcall
 /etc/init.d/xringd start|
 |
 |
 
   This has the -detach option so i can kill it 
 and the script will continue...
 
 
 
 Now, i have problems with /root/IP_MAIL, becouse it try to send me my ip 
 number before i can get one... this is how IP_mail looks:
 
 1)DAY=$(date +%A)
 2)NUMBER=$(date +%d)
 3)TIME=$(date +%r)
 4)MONTH=$(date +%m)
 5)IP=$(/sbin/ifconfig | grep inet | awk '{print $2}' |awk -F: '{print $2}' | 
 grep -v 127)
 6)echo Today, $DAY   $NUMBER/$MONTH  [$TIME] you have got an ip address: 
 $IP  /tmp/iptemporal.tmp
 7)mail -s Identidad: $IP [EMAIL PROTECTED]  /tmp/iptemporal.tmp
 
 
 in [EMAIL PROTECTED] i get:
 Today, Monday   26/10  [07:45:12 PM] you have got an ip address:
 
 
 so how can i make IP_MAIL do 1,2,3,4 and 5 until $IP is not empty ?? (is $IP 
 is not empty then go on and send the mail...)
 


Hmmm, What you need, is a script in /etc/ppp/ip-up.d/ to do this, but only
when 'pon incomingcall' is executed.. change your first script thus:

/etc/init.d/xringd stop
touch /tmp/make_IP_available
pon incomingcall
rm /tmp/make_IP_available
/etc/init.d/xringd start


place your second script in /etc/ppp/ip-up.d/ and start it with:

#!/bin/sh
test -f /tmp/make_IP_available || exit 0
...

so if the first script was called, it creates a temporary 0 byte file,
that the second script checks for. If it exists, it mails you with the IP
Address. 

   Michael Beattie ([EMAIL PROTECTED])

   PGP Key available, reply with pgpkey as subject.
 -
   Bother, said Pooh, as the rip cord came away in his hand
 -
Debian GNU/Linux  Ooohh You are missing out!



RE: Script help...............

1998-10-27 Thread Shaleh
Dunno why you are doing it this way so let me ask.  Why are you not using the
scripts in /etc/ppp/ip-{up,down}??  The IP address of the connection is passed
to the scripts on login.  So you are guaranteed to get a good IP.  If this is
not useful for some reason contact me and I can get your script working.


On 26-Oct-98 Phillip Neumann wrote:
 Hi debian world...
 
 
 
 
 Im not know very much about scripts so i need some help with one..
 
 Here my situation:
 
 A script will be executed when i call to my linux box... here it is: 
 
 /etc/init.d/xringd stop
 /root/IP_MAIL
 pon incomingcall
 /etc/init.d/xringd start|
 |
 |
 
   This has the -detach option so i can kill it
and the script will
 continue...
 
 
 
 Now, i have problems with /root/IP_MAIL, becouse it try to send me my ip
 number before i can get one... this is how IP_mail looks:
 
 1)DAY=$(date +%A)
 2)NUMBER=$(date +%d)
 3)TIME=$(date +%r)
 4)MONTH=$(date +%m)
 5)IP=$(/sbin/ifconfig | grep inet | awk '{print $2}' |awk -F: '{print $2}' |
 grep -v 127)
 6)echo Today, $DAY   $NUMBER/$MONTH  [$TIME] you have got an ip address:
 $IP  /tmp/iptemporal.tmp
 7)mail -s Identidad: $IP [EMAIL PROTECTED]  /tmp/iptemporal.tmp
 
 
 in [EMAIL PROTECTED] i get:
 Today, Monday   26/10  [07:45:12 PM] you have got an ip address:
 
 
 so how can i make IP_MAIL do 1,2,3,4 and 5 until $IP is not empty ?? (is $IP
 is not empty then go on and send the mail...)
 
 
 
 Thanks,
 Phillip Neumann
 [EMAIL PROTECTED]
 
 
 -- 
 Unsubscribe?  mail -s unsubscribe [EMAIL PROTECTED] 
 /dev/null

--
E-Mail: Shaleh [EMAIL PROTECTED]
Date: 26-Oct-98
Time: 23:21:09

This message was sent by XFMail
--


Re: Script help...............

1998-10-27 Thread Phillip Neumann
Michael Beattie wrote:

 On Mon, 26 Oct 1998, Phillip Neumann wrote:

  Hi debian world...
 
 
 
 
  Im not know very much about scripts so i need some help with one..
 
  Here my situation:
 
  A script will be executed when i call to my linux box... here it is:
 
  /etc/init.d/xringd stop
  /root/IP_MAIL
  pon incomingcall
  /etc/init.d/xringd start|
  |
  |
 
This has the -detach option so i can kill it 
  and the script will continue...
 
 
 
  Now, i have problems with /root/IP_MAIL, becouse it try to send me my ip 
  number before i can get one... this is how IP_mail looks:
 
  1)DAY=$(date +%A)
  2)NUMBER=$(date +%d)
  3)TIME=$(date +%r)
  4)MONTH=$(date +%m)
  5)IP=$(/sbin/ifconfig | grep inet | awk '{print $2}' |awk -F: '{print $2}' 
  | grep -v 127)
  6)echo Today, $DAY   $NUMBER/$MONTH  [$TIME] you have got an ip address: 
  $IP  /tmp/iptemporal.tmp
  7)mail -s Identidad: $IP [EMAIL PROTECTED]  /tmp/iptemporal.tmp
 
 
  in [EMAIL PROTECTED] i get:
  Today, Monday   26/10  [07:45:12 PM] you have got an ip address:
 
 
  so how can i make IP_MAIL do 1,2,3,4 and 5 until $IP is not empty ?? (is 
  $IP is not empty then go on and send the mail...)
 

 Hmmm, What you need, is a script in /etc/ppp/ip-up.d/ to do this, but only
 when 'pon incomingcall' is executed.. change your first script thus:

 /etc/init.d/xringd stop
 touch /tmp/make_IP_available
 pon incomingcall
 rm /tmp/make_IP_available
 /etc/init.d/xringd start

 place your second script in /etc/ppp/ip-up.d/ and start it with:

 #!/bin/sh
 test -f /tmp/make_IP_available || exit 0
 ...

 so if the first script was called, it creates a temporary 0 byte file,
 that the second script checks for. If it exists, it mails you with the IP
 Address.

Michael Beattie ([EMAIL PROTECTED])

PGP Key available, reply with pgpkey as subject.
  -
Bother, said Pooh, as the rip cord came away in his hand
  -
 Debian GNU/Linux  Ooohh You are missing out!

Hello



Well thanks, i finnaly got this working   8-]


bye,

--
 __
/ /
   /  Phillip  Neumann   /
  / [EMAIL PROTECTED]  /
_/_/




Re: sed/grep script help

1997-08-07 Thread Oliver Elphick
In message [EMAIL PROTECTED], write
s:
  I'm modifying the pinepgp scripts to work with PGP 5.0... the output is
  somewhat different then the previous version.  Anyhow I'm new to these
  programs and heres the output:
  
  Good signature made 1997-08-06 15:10 GMT by key:
1024 bits, Key ID 8C111B46, Created 1997-08-06
 Paul A. Miller [EMAIL PROTECTED]
  
  I want it transformed into:
  
  Good signatuure by Paul A. Miller [EMAIL PROTECTED]
  
  Anyone have any ideas?
  
awk -F\ '/^Good/{printf(Good signature by )}
/^ */{print $2}'

Example:
$ echo 'Good signature made 1997-08-06 15:10 GMT by key:
   1024 bits, Key ID 8C111B46, Created 1997-08-06
Paul A. Miller [EMAIL PROTECTED]'|
awk -F\ '/^Good/{printf(Good signature by )}
 /^ */{print $2}'
Good signature by Paul A. Miller [EMAIL PROTECTED]

-- 
Oliver Elphick[EMAIL PROTECTED]
Isle of Wight  http://lfix.co.uk/oliver

 Make it idiot-proof, and someone will breed a better idiot.



--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .


sed/grep script help

1997-08-06 Thread Paul Miller
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I'm modifying the pinepgp scripts to work with PGP 5.0... the output is
somewhat different then the previous version.  Anyhow I'm new to these
programs and heres the output:

Good signature made 1997-08-06 15:10 GMT by key:
  1024 bits, Key ID 8C111B46, Created 1997-08-06
   Paul A. Miller [EMAIL PROTECTED]

I want it transformed into:

Good signatuure by Paul A. Miller [EMAIL PROTECTED]

Anyone have any ideas?

- -Paul

-BEGIN PGP SIGNATURE-
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBM+jz8mUINiyMERtGEQIZ2gCgpKYQ+MHaoJ+Zu2iv0SOIcqZ67jYAniB3
NeEJzbuiwKomj+tg0JL978t/
=iIMc
-END PGP SIGNATURE-


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .


Re: Script help

1997-06-12 Thread gvl
kill -l for a list of the names attached to the numbers

man 7 signal for a more exhaustive explanation.

On 10 Jun 97,  Andy J. Smith wrote regarding:
__ Re: Script help __

 On Mon, 9 Jun 1997, J. Paul Reed wrote:
 
 [different types of signals]
 
  Do you know what -1 to -?? does? I've always wondered, since I've only
  ever used -9 and -15.
 
 There's a man page that lists them all.  signals I think it is called,
 but if not, a man -k signal would probably show it.
Gerald V. Livingston II

Reply to [EMAIL PROTECTED]


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .