Re: mktime() output not the same as the date utility

2008-10-14 Thread Mark B.
On Tue, Oct 14, 2008 at 1:50 PM, Jeremy Chadwick <[EMAIL PROTECTED]> wrote:
> On Tue, Oct 14, 2008 at 12:43:54PM -0400, Mark B. wrote:
>> I can't figure out from the man pages why
>> mktime() is giving a different result than date -f.
>> Both strptime and mktime are supposed to use the
>> local timezone, as does date.
>>
>> The output of date is correct; mktime() is an hour later.
>>
>> What am I missing here?
>
> I'm betting it's due to DST
>

Yes, set tm_isdst to -1 before calling mktime() and then my
test program works as expected.

Thanks,

m
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


mktime() output not the same as the date utility

2008-10-14 Thread Mark B.
Hi,

I can't figure out from the man pages why
mktime() is giving a different result than date -f.
Both strptime and mktime are supposed to use the
local timezone, as does date.

The output of date is correct; mktime() is an hour later.

What am I missing here?

Thanks,

m

$ uname -s; uname -r
FreeBSD
6.0-RELEASE-p9


$ gcc test.c
$ ./a.out
date -j -f "%Y-%m-%d %H:%M:%S" "2008-10-14 08:06:21" +%s returns 1223985981
a.out: tm.tm_sec= 21
a.out: tm.tm_min= 6
a.out: tm.tm_hour   = 8
a.out: tm.tm_mday   = 14
a.out: tm.tm_mon= 9
a.out: tm.tm_year   = 108
a.out: tm.tm_wday   = 0
a.out: tm.tm_yday   = 0
a.out: tm.tm_isdst  = 0
a.out: tm.tm_zone   = (null)
a.out: tm.tm_gmtoff = 0
exp 1223985981, got 1223989581: delta = -3600


$ date -j -r 1223985981
Tue Oct 14 08:06:21 EDT 2008
$ date -j -r 1223989581
Tue Oct 14 09:06:21 EDT 2008


$ cat test.c
#include 
#include 

#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define EXITOK(rc)  (WIFEXITED(rc) && WEXITSTATUS(rc) == 0)

static char *time_s = "2008-10-14 08:06:21";
static char *fmt= "%Y-%m-%d %H:%M:%S";

/* Return seconds since epoch computed from date utility. */
time_t
expected()
{
char cmd[500] = {0};
char outbuf[4096];
unsigned longexp, act;
int  rc;
FILE*pfp;

/* date -j -f "%Y-%m-%d %H:%M:%S" "2008-10-14 08:06:21" +%s */
(void) snprintf(cmd, sizeof(cmd),
"date -j -f \"%s\" \"%s\" +%%s", fmt, time_s);

if ((pfp = popen(cmd, "r")) == NULL)
errx(1, "popen failed.");
while (fgets(outbuf, sizeof(outbuf), pfp) != NULL)
printf("%s returns %s", cmd, outbuf);
if((rc = pclose(pfp)) == -1)
errx(1, "pclose returns -1");
if (!EXITOK(rc))
errx(1, "%s didn't terminate normally", cmd);

return (time_t) strtoul(outbuf, 0, 10);
}


/* Returns seconds since epoch using strptime() and mktime() */
time_t
actual()
{
struct tm   tm;
time_t   rval;

rval = (time_t) 0;

memset(&tm, 0, sizeof(tm));
if (strptime(time_s, fmt, &tm) == NULL)
errx(1, "fmt '%s' didn't match '%s'", fmt, time_s);

warnx("tm.tm_sec= %d", tm.tm_sec);
warnx("tm.tm_min= %d", tm.tm_min);
warnx("tm.tm_hour   = %d", tm.tm_hour);
warnx("tm.tm_mday   = %d", tm.tm_mday);
warnx("tm.tm_mon= %d", tm.tm_mon);
warnx("tm.tm_year   = %d", tm.tm_year);
warnx("tm.tm_wday   = %d", tm.tm_wday);
warnx("tm.tm_yday   = %d", tm.tm_yday);
warnx("tm.tm_isdst  = %d", tm.tm_isdst);
warnx("tm.tm_zone   = %s", tm.tm_zone);
warnx("tm.tm_gmtoff = %lu", tm.tm_gmtoff);

return mktime(&tm);
}



int
main(void)
{
time_t  act, exp;
double  delta;

exp = expected();
act = actual();

delta = difftime(exp, act);
if (fabs(delta) > DBL_EPSILON) {
printf("exp %llu, got %llu: delta = %.0f\n",
(long long int) exp, (long long int) act,
delta);
return 1;
}
else
return 0;

}
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: How to delete non-ASCII chars in file

2008-09-05 Thread Mark B.
On Fri, Sep 5, 2008 at 1:38 PM, Giorgos Keramidas <[EMAIL PROTECTED]> wrote:

> Does this look ok?

Looks good to me.

m
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: How to delete non-ASCII chars in file

2008-09-05 Thread Mark B.
On Fri, Sep 5, 2008 at 12:27 PM, Mark B. <[EMAIL PROTECTED]> wrote:
> A follow question--is it possible to use that statement in a Makefile (BSD)?
> A straight cut 'n paste didn't work, and I couldn't figure out the escaping to
> make it work.

Never mind, it works just fine.

m
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: How to delete non-ASCII chars in file

2008-09-05 Thread Mark B.
On Fri, Sep 5, 2008 at 10:58 AM, Giorgos Keramidas
<[EMAIL PROTECTED]> wrote:

> $ echo '^Fhello^F' | sed -e 's/[^[:print:]]*//' | hd
>   68 65 6c 6c 6f 06 0a  |hello..|
> 0007
> $

Thanks.

> The matching pattern is wrong.  You need `[^[:print:]]'.  The character
> class of printable characters is `[:print:]', and you can negate the
> pattern with `[^]' where `' is the character class; hence the
> extra pair of brackets in `[^[:print:]]'.

In case you are interested, I've patched the re_format man page with this
example.  I had read it, and it says :print: is the "name of the character
class."  I think the concrete example helps clarify things.

A follow question--is it possible to use that statement in a Makefile (BSD)?
A straight cut 'n paste didn't work, and I couldn't figure out the escaping to
make it work.

Thanks,

m

cd to /usr/src/lib/libc/regex/ and apply this patch.

--- /dev/null Fri Sep  5 12:12:21 2008
+++ re_format.7Fri Sep  5 12:18:29 2008
@@ -288,6 +288,10 @@
 A locale may provide others.
 A character class may not be used as an endpoint of a range.
 .Pp
+To match all characters not in a class, use a bracket expression
+like this:
+.Ql [^[:print:]] .
+.Pp
 There are two special cases\(dd of bracket expressions:
 the bracket expressions
 .Ql [[:<:]]
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


How to delete non-ASCII chars in file

2008-09-05 Thread Mark B.
I have a text file that includes some non-ASCII characters
For example, opening the file in vi shows lines like this:

 'easth_0.541716776378'  0   \xe2\x80\x98dire'   2

Is there a command-line tool I can use to delete these
characters?  I tried:

cat f | tr -cd [:print:]

but this removes the newlines.

I also tried

   cat f | sed "s/[^:print:]//g"

but it didn't remove the characters.

Thanks,

m
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: multi-platform dump and restore?

2008-07-02 Thread Mark B.
On Wed, Jul 2, 2008 at 12:21 PM, Wojciech Puchar
<[EMAIL PROTECTED]> wrote:
>> If I dump on amd64 should I be able to
>> extract files from the dump on i386?
>
> i'm almost sure yes but please check
>

I did and it does.

>>
>> If so, should it be possible to restore a
>> FreeBSD amd64 dump on OpenBSD i386?
>
> probably not.
>

You are correct.

# gunzip -c var_www_log.1214712054.1.dmp.gz | restore -i -f -
. is not on the tape
Root directory is not on tape
abort? [yn] y
dump core? [yn] n
# uname -a
OpenBSD dev.example.com 4.2 GENERIC#375 i386

How did you guess?

m
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


multi-platform dump and restore?

2008-07-02 Thread Mark B.
If I dump on amd64 should I be able to
extract files from the dump on i386?

If so, should it be possible to restore a
FreeBSD amd64 dump on OpenBSD i386?

Note there is ticket that may be related:

 bin/67723:

 restore(8) FreeBSD 5.x restore cannot handle
 other platforms/Linux(extfs)-dumps anymore

ref: http://www.freebsd.org/cgi/query-pr.cgi?pr=67723&cat=

I thought the dump file format was sacrosanct.
Has there been heresy here?

Thanks,

m

P.S. Please CC, I'm not subscribed.  Thanks.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


df: negative "Used" and "Capacity" -- file system corruption?

2008-06-18 Thread Mark B.
Hi,

FreeBSD 7, AMD64.

$ df -h
Filesystem SizeUsed   Avail Capacity  Mounted on
/dev/da0s1d2.9G-67M2.7G-2%/var/www

$ mount
/dev/da0s1d on /var/www (ufs, local, soft-updates)
$

I found an email thread from 2006 where Suleiman Souhlal says the
culprit was a stale cylinder group [1].

Any ideas on what's going on?  I'm concerned there is a hardware problem.

The only hardware messages I've ever seen are:  ciss0: *** SCSI bus
speed downshifted, SCSI port 2, and I got that message only twice
twice in over six months.

There was a bug report [2], but it was closed after telling user to
"fsck -f".  (Which I will do tomorrow morning.)

Thanks,

m

[1] http://marc.info/?l=freebsd-stable&m=111837454806848&w=2
[2] http://www.freebsd.org/cgi/query-pr.cgi?pr=92432&cat=
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


make world error

2003-10-06 Thread mark . b
On a make world on a 4.8 box, this is the error msg

===> gnu/usr.bin/cc/cccp
cc -O -pipe  -DIN_GCC -DHAVE_CONFIG_H -DPREFIX=\"/usr/obj/usr/src/i386/usr\" 
-I/usr/obj/usr/src/i386/usr/src/gnu/usr.bin/cc/cccp/../cc_tools -
I/usr/src/gnu/usr.bin/cc/cccp/../cc_tools -
I/usr/src/gnu/usr.bin/cc/cccp/../../../../contrib/gcc -
I/usr/src/gnu/usr.bin/cc/cccp/../../../../contrib/gcc/config-D__FBSDID=__RCSID -c 
/usr/src/gnu/usr.bin/cc/cccp/../../../../contrib/gcc/cccp.c
{standard input}: cc: Assembler messages:
{standard input}:7083: Warning: end of file not at end of a line; newline inserted
Internal compiler error: program cc1 got fatal signal 11
*** Error code 1

Stop in /usr/src/gnu/usr.bin/cc/cccp.
*** Error code 1

Stop in /usr/src/gnu/usr.bin/cc.
*** Error code 1

Stop in /usr/src.
*** Error code 1

Stop in /usr/src.
*** Error code 1

Stop in /usr/src.

#end error

I waited a day did a new cvsup, thinking it was a new code errror,  but I get the same 
msg.

Any ideas??
 
 

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: burncd on 4.7 + YAMAHA CRW2200E (again)

2002-11-15 Thread mark . b
Just a stab in the dark, When I got my first cd burner, it would not burn but would 
read cd's
fine, the problem was the burner had to use the "master plug" on the IDE cable.


On 15 Nov 2002 at 17:49, Jacques Beigbeder wrote:

Date sent:  Fri, 15 Nov 2002 17:49:30 +0100
From:   Jacques Beigbeder <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject:burncd on 4.7 + YAMAHA CRW2200E (again)

> Hardware: PC Asus / Athlon processor
> OS : FreeBSD 4.7, GENERIC kernel
>
> During the boot, I read in syslog messages:
>  ata1-slave: ATAPI identify retries exceeded
>  ad0: 19546MB  [39714/16/63] at ata0-master
>  UDMA100 acd0: CD-RW  at ata1-master PIO4
> So the hard drive is primary master, the CD is secondary master.
>
> The CD works since I can mount data CD. It works under Linux
> with cdrecord.
>
> I can write CD-RW with:
>  burncd -f /dev/acd0c blank
>  burncd -f /dev/acd0c data MY_ISO_IMAGE fixate
> But with a CD-R the same (second) command fails and /var/log/messages
> says:
>
> Nov 15 14:56:58 tempo2 /kernel: acd0: SEND_OPC_INFO command timeout -
> resetting Nov 15 14:56:58 tempo2 /kernel: ata1: resetting devices ..
> ata1-slave: ATAPI identify retries exceeded Nov 15 14:56:58 tempo2
> /kernel: done
>
> Just once; what's about "ATAPI identify retries exceeded'? There's
> nothing slave! Than, with a loop:
>
> Nov 15 14:57:56 tempo2 /kernel: acd0: SEND_OPC_INFO command timeout -
> resetting Nov 15 14:57:56 tempo2 /kernel: ata1: resetting devices ..
> done Nov 15 14:59:13 tempo2 /kernel: acd0: SEND_OPC_INFO command
> timeout - resetting Nov 15 14:59:13 tempo2 /kernel: ata1: resetting
> devices .. done
>
> Any hint? Thanks in advance,
>
> --
> Jacques Beigbeder|  [EMAIL PROTECTED]
> Service de Prestations Informatiques | http://www.spi.ens.fr
> Ecole normale supérieure |
> 45 rue d'Ulm |Tel : (+33 1)1 44 32 37 96
> F75230 Paris cedex 05|Fax : (+33 1)1 44 32 20 75
>
>
> To Unsubscribe: send mail to [EMAIL PROTECTED]
> with "unsubscribe freebsd-questions" in the body of the message


* *  *   *   * *   * * *
** *   *   *   *   *   *
 *   *

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



upsd - aps smartups 700 error

2002-10-23 Thread mark . b
I loaded upsd on a 4.5 box for a APS Smartups 700 and started getting this msg in 
/var/log/messages and security output.

> Oct 22 16:30:46 chillhd upsd[110]: apc_tune: negative response:NO
> Oct 22 16:40:46 chillhd upsd[110]: apc_tune: negative response:NO
> Oct 22 16:50:46 chillhd upsd[110]: apc_tune: negative response:NO
> Oct 22 17:00:46 chillhd upsd[110]: apc_tune: negative response:NO
> Oct 22 17:10:46 chillhd upsd[110]: apc_tune: negative response:NO

I did a search for some man pages and/or config help for upsd but have not had any 
luck 
finding any docs, any info will help, thanks

I have tried to comment out part of the tune function but nothing changes.

here is the conf file I am using

 /usr/local/etc/upsd.conf
# $FreeBSD: ports/sysutils/upsd/files/upsd.conf,v 1.2 1999/08/31 02:00:16 peter Exp $
#
# UPS Daemon
# The Wild Wind Communications, 1995, 1996
#
# See file LICENSE for the distribution terms of this software.
#

ups "smart-ups" (230) proto "apc-smart" {
device  "/dev/cuaa0"
speed   2400
read-timeout2
write-block-size1
write-block-delay   50
queue-size  64
}

every 5 { # check events every 5 seconds
nop
}

on "initialize" != "SM" {
poll "initialize"
after 60 every 60 {
log emerg "Cannot put the UPS into smart mode!"
}
}

every 600 {
tune "high-transfer-point"  264
tune "low-transfer-point"   196
tune "line-alarm"   "0"
tune "line-sensitivity" "L"
tune "low-batteries-duration"   2
tune "nominal-voltage"  220
tune "shutdown-delay"   20
tune "wakeup-batteries-capacity"25
tune "wakeup-delay" 0
#   tune "batteries-replaced"   "01/01/77"
file "upsd.conf", 100 lines



* *  *   *   * *   * * *
** *   *   *   *   *   *
 *   *

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



/kernel write failed system full

2002-07-22 Thread Mark B

OK I know I did something wrong, but with little chance to correct the system, with 
error messages spewing out at a blinding rate, I hit the reset button then fsck the 
disks on boot, then edit the fstab to block off all but the basic fs needed to run. I 
see first error was a /kernel msg complaining about netscape-linux write error, over 
400,000 of repetes, then everything got worse, is there a way to span the system over 
2 ide disks, I have a 3gig drive and a 25 gig drive. 
I think my main problem was running netscape as root. 8-(

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



/kernel write failed system full

2002-07-22 Thread Mark B

OK I know I did something wrong, but with little chance to correct the system, with 
error messages spewing out at a blinding rate, I hit the reset button then fsck the 
disks on boot, then edit the fstab to block off all but the basic fs needed to run. I 
see first error was a /kernel msg complaining about netscape-linux write error, over 
400,000 of repetes, then everything got worse, is there a way to span the system over 
2 ide disks, I have a 3gig drive and a 25 gig drive. 
I think my main problem was running netscape as root. 8-(

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message