LC_ALL for daemons

2004-04-30 Thread Joel Rees
I'm sure I've seen a thread on this, but a casual search didn't turn it 
up. (I'm always looking in the wrong places.)

When I'm logged in as a user, I can set the appropriate environmen 
variables, but when a daemon is running, where is it going to get them?

Joel Rees


comparison always false is a problem or not?

2004-04-30 Thread Joel Rees
My experience is that this kind of thing tends to lead to dead code or 
endless loops. Do I need to dig in and find the macro declaration and 
see if I can fix it?

warning: comparison is always false due to limited range of data 
type

regcomp.c:724
pp_sys.c:302
byterun.c:898
re_comp.c:724
Joel Rees


Re: LC_ALL for daemons

2004-04-30 Thread Sherm Pendley
On Apr 30, 2004, at 2:24 AM, Joel Rees wrote:
When I'm logged in as a user, I can set the appropriate environmen 
variables, but when a daemon is running, where is it going to get 
them?
Daemons are started from scripts found in /System/Library/StartupItems 
(for Apple-provided daemons), or /Library/StartupItems (for your own).

Startup scripts usually include /etc/rc.common, so if you want to 
export an env variable for *all* daemons, that would be a good place to 
do it. Be aware that /etc/rc.common is a system file though; 
Apple-supplied OS updates might overwrite it, so keep a backup just in 
case.

If you're writing a daemon, you might also want to be aware of 
/etc/hostconfig. This sets a series of flags that indicate what daemons 
should be started. At system startup, *all* of the items in the 
StartupItems folders are run, so they check for the corresponding flag 
to see if they should actually start their service.

sherm--


Re: comparison always false is a problem or not?

2004-04-30 Thread Sherm Pendley
On Apr 30, 2004, at 2:30 AM, Joel Rees wrote:
My experience is that this kind of thing tends to lead to dead code or 
endless loops. Do I need to dig in and find the macro declaration and 
see if I can fix it?

warning: comparison is always false due to limited range of data 
type
In my own code, I compile with -Wall and try to chase down and 
eliminate all warnings. Occasionally I might use a -Wno-something to 
turn off a warning once I've determined that it's harmless, but I 
really, really prefer to fix them.

I treat other people's code differently. If I'm building something from 
source and it emits warnings, I'll make a mental note of that fact. 
Then, if it's crashy, buggy, or exhibits some other odd behavior, I 
might go back and see if the warnings are relevant to the problems. If 
the app works fine though, I don't worry about the warnings.

Those file names look familiar - are you building Perl? If so, and the 
self-tests pass, I definitely wouldn't worry about the warnings too 
much. Perl's self-tests are remarkably thorough.

sherm--


Re: comparison always false is a problem or not?

2004-04-30 Thread Joel Rees
On 2004.4.30, at 04:38 PM, Sherm Pendley wrote:

 On Apr 30, 2004, at 2:30 AM, Joel Rees wrote:

 My experience is that this kind of thing tends to lead to dead code  
 or endless loops. Do I need to dig in and find the macro declaration  
 and see if I can fix it?

 warning: comparison is always false due to limited range of data  
 type

 In my own code, I compile with -Wall and try to chase down and  
 eliminate all warnings. Occasionally I might use a -Wno-something to  
 turn off a warning once I've determined that it's harmless, but I  
 really, really prefer to fix them.

Me too.

 I treat other people's code differently. If I'm building something  
 from source and it emits warnings, I'll make a mental note of that  
 fact. Then, if it's crashy, buggy, or exhibits some other odd  
 behavior, I might go back and see if the warnings are relevant to the  
 problems. If the app works fine though, I don't worry about the  
 warnings.

That's kind of what I was figuring would do, but I also would prefer  
not to find my code skipping a parse because the code got thrown out.  
So I thought I'd check.

 Those file names look familiar - are you building Perl?

Of course! (I suppose I should have said so.)

  If so, and the self-tests pass,

Well, since you're kind enough to ask (heh heh), here's a few more I  
get:

In the make phase,

 ...
 cc -flat_namespace -L/usr/local/lib  -o miniperl ¥
 miniperlmain.o opmini.o libperl.a -lm -lc
 ./miniperl -w -Ilib -MExporter -e '?' || make minitest
 make: [extra.pods] Error 1 (ignored)
 ./miniperl -Ilib configpm configpm.tmp
 sh mv-if-diff configpm.tmp lib/Config.pm
 ...
 Making Errno (nonxs)
 Writing Makefile for Errno
 ../../miniperl "-I../../lib" "-I../../lib" "-I../../lib"  
"-I../../lib" Errno_pm.PL Errno.pm
 cp Errno.pm ../../lib/Errno.pm
 make: [extras.make] Error 1 (ignored)

 Everything is up to date. Type 'make test' to run test  
suite.

and also the range warnings mentioned already. In the make test phase,

 ...
 ext/DB_File/t/db-btree...#
 # This test is known to crash in Mac OS X versions 10.2 (or earlier)
 # because of the buggy Berkeley DB version included with the OS.
 #
 FAILED at test 0
 ext/DB_File/t/db-hashok
 ext/DB_File/t/db-recno...#
 # Some older versions of Berkeley DB version 1 will fail db-recno
 # tests 61, 63, 64 and 65.
 ...
 # You can safely ignore the errors if you're never going to use the
 ...
 #
 FAILED at test 64
 ext/Devel/DProf/t/DProf..ok
 ...
 Failed 2 test scripts out of 804, 99.75% okay.
 ### Since not all tests were successful, you may want to run some of
 ...
 ### Bourne-style shells, like bash, ksh, and zsh, respectively.
 u=25.78  s=0  cu=599.71  cs=171.77  scripts=804  tests=80310
 make[2]: *** [_test_tty] Error 1
 make[1]: *** [_test] Error 2
 make: *** [test] Error 2

It says I can ignore those, so I did a make install and got

...
 Making Errno (nonxs)
 make[1]: [extras.make] Error 1 (ignored)

 Everything is up to date. Type 'make test' to run test  
suite.
 if [ -n "" ]; ¥
 then ¥
 cd utils; make compile; ¥
 cd ../x2p; make compile; ¥
 cd ../pod; make compile; ¥
 else :; ¥
 fi
 ./perl installperl --destdir=
 WARNING: You've never run 'make test' or some tests failed!  
(Installing anyway.)

which worried me a little. So I went ahead and ran t/harness after the  
install completed. (That's backwards, I suppose.):

 ...
 op/lex_assign..ok
 op/lfs.skipped
 all skipped: writing past 2GB failed: process limits?
 op/listok
 ...
 ../ext/DB_File/t/db-btree..#
 # This test is known to crash in Mac OS X versions 10.2 (or earlier)
 # because of the buggy Berkeley DB version included with the OS.
 #
 ../ext/DB_File/t/db-btree..dubious
 Test returned status 0 (wstat 10, 0xa)
 ../ext/DB_File/t/db-hash...ok
 ../ext/DB_File/t/db-recno..#
 # Some older versions of Berkeley DB version 1 will fail db-recno
 # tests 61, 63, 64 and 65.
 #
 # For example Mac OS X 10.2 (or earlier) has such an old
 ...
 ../ext/DB_File/t/db-recno..FAILED tests 64, 67, 70
  

Re: LC_ALL for daemons

2004-04-30 Thread Joel Rees
On 2004.4.30, at 04:30 PM, Sherm Pendley wrote:
On Apr 30, 2004, at 2:24 AM, Joel Rees wrote:
When I'm logged in as a user, I can set the appropriate environmen 
variables, but when a daemon is running, where is it going to get 
them?
Daemons are started from scripts found in /System/Library/StartupItems 
(for Apple-provided daemons), or /Library/StartupItems (for your own).

Startup scripts usually include /etc/rc.common, so if you want to 
export an env variable for *all* daemons, that would be a good place 
to do it. Be aware that /etc/rc.common is a system file though; 
Apple-supplied OS updates might overwrite it, so keep a backup just in 
case.
Thanks. I needed that information, because I had forgotten that Mac OS 
X doesn't use the rc/* convention. Don't look like there are any hooks 
for an rc.local. An rc script for the daemon would be handy for setting 
an environment variable.

Hmm. There are plists in those startup items. I wonder if I can pervert 
those. Time to dig out my copy of in-a-nutshell and see if there are 
enought clues there.

If you're writing a daemon,
Well, I'm still vacillating between a cron job and a daemon. I'm 
writing my own update tool for dynamic dns for the experience. (My ISP 
wants $60 a month for one static IP.) It'll screen-scrape the 
router/modem's setup pages for some Japanese text. I'm sure I could 
modify somebody else's script, but I have this cowboy mentality, at 
least until I learn how to read Perl for meaning instead of just 
function.

you might also want to be aware of /etc/hostconfig.
Yeah, I needed to look in there, too.
This sets a series of flags that indicate what daemons should be 
started. At system startup, *all* of the items in the StartupItems 
folders are run, so they check for the corresponding flag to see if 
they should actually start their service.
Yep, that's where I can turn sendmail on, once I figure out some 
configuration details, and I want that so my script can report problems 
updating and not just log them. Well, that's for another day.

Thanks, Sherm. I have to admit I get lost less with a little prompting.
--
Joel Rees


questions from configure

2004-04-30 Thread Joel Rees
Okay, one more that had me curious, from the configure script --
vfork() found.
Perl can only use a vfork() that doesn't suffer from strict
restrictions on calling functions or modifying global data in
the child.  For example, glibc-2.1 contains such a vfork()
that is unsuitable.  If your system provides a proper fork()
call, chances are that you do NOT want perl to use vfork().
Do you still want to use vfork()? [y]
Do I take this to mean that Mac OS X (10.2.8) still doesn't have a 
proper fork for Perl's purposes? (for Perl 5.8.4)

And, the default configure suggesting against threads, is that because 
Perl's threads are still in the oven, or because Mac OS X's threads are 
still a little unripe, so to speak?

--
Joel Rees


Re: LC_ALL for daemons

2004-04-30 Thread Sherm Pendley
On Apr 30, 2004, at 7:28 AM, Joel Rees wrote:
Thanks. I needed that information, because I had forgotten that Mac OS 
X doesn't use the rc/* convention. Don't look like there are any hooks 
for an rc.local. An rc script for the daemon would be handy for 
setting an environment variable.
Each StartupItem directory has a like-named script inside it. You can 
set and export the environment variable from that script. The scripts 
are called just like rc scripts, with start/stop/restart parameters. 
(Actually, I'm not certain if 'stop' scripts are called on Panther - 
they're definitely not called under Jaguar and earlier.)

You can write the script in Perl if you'd like, although all of the 
standard scripts use /bin/sh. I usually just copy an existing script 
and alter it a bit.

Hmm. There are plists in those startup items. I wonder if I can 
pervert those. Time to dig out my copy of in-a-nutshell and see if 
there are enought clues there.
Those are used to help determine the order in which the services are 
started, using the Provides, Requires, and Uses arrays. For 
example, the Network item provides (no surprise here) the Network 
service. The MySQL item uses that service, and provides the (shock!) 
MySQL service.

At system startup, items are sorted so that the ones that provide a 
given service are started before the ones that use or require it.

Overall, I think it's a much more elegant system than the old numbered 
rc files scheme. That scheme always brings back unpleasant memories of 
having to renumber lines of BASIC.

sherm--


Re: questions from configure

2004-04-30 Thread Sherm Pendley
On Apr 30, 2004, at 7:29 AM, Joel Rees wrote:
Okay, one more that had me curious, from the configure script --
vfork() found.
Do you still want to use vfork()? [y]
Do I take this to mean that Mac OS X (10.2.8) still doesn't have a 
proper fork for Perl's purposes? (for Perl 5.8.4)
Dunno. I do know that Mac OS X has its own libc, so GNU's glibc isn't 
an issue here. I defer to the wisdom of the wizards who wrote the hints 
file on this one, and accept the default.

And, the default configure suggesting against threads, is that because 
Perl's threads are still in the oven, or because Mac OS X's threads 
are still a little unripe, so to speak?
Mac OS X 10.2's libc has some threading problems. Some re-entrant 
functions aren't present, and some are present but aren't really 
re-entrant. So threading support is disabled by default on 10.2.

On 10.3 the threading issues in libc have been corrected. The 5.8.1 
that ships standard is thread-enabled, and all of the threading 
self-tests pass without complaint.

sherm--


backing up system

2004-04-30 Thread Joseph Alotta
Greetings,
I try to back up my system once a week.  I have a firewire disk drive 
that I use for this purpose.  I have been using the Lacie software that 
came with it.  Before Panther, I used to be able just to plug it in and 
run it under my own id.  Now I need to log in as root to run it. Which 
means I can't do anything else until it finishes, and it takes about 40 
minutes.

I am looking to do something more automatic.
Questions:
1. Can iSync be used for backups?  I'm not sure if I have iSync unless 
it is standard in Panther.

2. Otherwise, has someone wrote a perl program to do this that I can 
run in cron.

Thank you so much,
Joe.


Re: backing up system

2004-04-30 Thread Jerry LeVan
I use DejaVu for periodic backing up of important folders. It runs as a 
preference panel, uses
cron and psync.

If you want to use cron and let your system go to sleep then you might 
want to take a look
some of the stuff I have at http://homepage.mac.com/levanj/Cocoa. It 
turns out you have to
do a little song and dance to make sure the mac is awake (for a long 
enough period) when
cron fires.

Jerry
On Apr 30, 2004, at 4:22 PM, Joseph Alotta wrote:
Greetings,
I try to back up my system once a week.  I have a firewire disk drive 
that I use for this purpose.  I have been using the Lacie software 
that came with it.  Before Panther, I used to be able just to plug it 
in and run it under my own id.  Now I need to log in as root to run 
it. Which means I can't do anything else until it finishes, and it 
takes about 40 minutes.

I am looking to do something more automatic.
Questions:
1. Can iSync be used for backups?  I'm not sure if I have iSync unless 
it is standard in Panther.

2. Otherwise, has someone wrote a perl program to do this that I can 
run in cron.

Thank you so much,
Joe.



Re: backing up system

2004-04-30 Thread Chris Devers
On Fri, 30 Apr 2004, Jerry LeVan wrote:

 If you want to use cron and let your system go to sleep then you might
 want to take a look some of the stuff I have at
 http://homepage.mac.com/levanj/Cocoa. It turns out you have to do a
 little song and dance to make sure the mac is awake (for a long enough
 period) when cron fires.

Isn't that the sort of problem that Anacron is supposed to solve?

http://anacron.sourceforge.net/

Seems like it might make this sort of thing easier...


-- 
Chris Devers


Re: backing up system

2004-04-30 Thread Sherm Pendley
On Apr 30, 2004, at 4:36 PM, Jerry LeVan wrote:
If you want to use cron and let your system go to sleep then you might 
want to take a look
some of the stuff I have at http://homepage.mac.com/levanj/Cocoa. It 
turns out you have to
do a little song and dance to make sure the mac is awake (for a long 
enough period) when
cron fires.
Or you could use anacron:
http://anacron.sourceforge.net/
http://sourceforge.net/projects/anacron
There's a Fink package too.
sherm--


Re: backing up system

2004-04-30 Thread Jerry LeVan
Anacron does not appear to run cron jobs at at particular time, the 
dailyWakeup/keypress/cron
combination can insure that the cron job is run on time. If you want, 
dailyWakeup can even
restart the system to get going :) If you want a hands on approach 
PMQueueManager will allow
you to schedule any many PM events as you want.

Jerry
On Apr 30, 2004, at 4:57 PM, Sherm Pendley wrote:
On Apr 30, 2004, at 4:36 PM, Jerry LeVan wrote:
If you want to use cron and let your system go to sleep then you 
might want to take a look
some of the stuff I have at http://homepage.mac.com/levanj/Cocoa. It 
turns out you have to
do a little song and dance to make sure the mac is awake (for a long 
enough period) when
cron fires.
Or you could use anacron:
http://anacron.sourceforge.net/
http://sourceforge.net/projects/anacron
There's a Fink package too.
sherm--



Re: backing up system

2004-04-30 Thread Chris Devers
On Fri, 30 Apr 2004, Jerry LeVan wrote:

 Anacron does not appear to run cron jobs at at particular time

Yeah, that's the whole point.

The emphasis shifts from I want this maintainence script to run at 3:47
am every Sunday night to this maintainence script needs run once a
week, preferably when you're not doing anything else. More often than
not, the latter is all that's really required.

Anacron considers the problem from a different point of view, and for a
lot of people's needs, this may be more appropriate than the traditional
approach.

They come right out and say on their home page that this isn't meant to
replace the traditional Cron system, but rather to supplement it for
people with different usage patterns (laptops, people who turn their
machine off at night, etc).


-- 
Chris Devers


Re: backing up system

2004-04-30 Thread Joel Rees
Perhaps it's because I'm not strong on Perl yet, but I took a bit more 
of a naive view here --

On 2004.5.1, at 05:22 AM, Joseph Alotta wrote:
Greetings,
I try to back up my system once a week.  I have a firewire disk drive 
that I use for this purpose.  I have been using the Lacie software 
that came with it.  Before Panther, I used to be able just to plug it 
in and run it under my own id.  Now I need to log in as root to run 
it. Which means I can't do anything else until it finishes,
Does logging in concurrently as root not work?
Not that I'd urge you to leave your root account enabled for logging 
in, concurrently or otherwise.

(I just tried, for grins, under 10.2.8, su-ing to an admin user, then 
sudo-ing a sh to get a root shell without logging in as root, but 
open-ing /Applications/AppleWorks 6 as the root user didn't seem to 
do anything other than opening the /Applications directory in a GUI 
window. open-ing /Applications/TextEdit.app as root runs TextEdit, 
but the process is owned by the user I'm logged in as. sudoing the open 
directly from the admin user yields complaints about not being able to 
map display interlocks or open default connections, etc. That's not 
Panther, of course.)

 and it takes about 40 minutes.
I am looking to do something more automatic.
Questions:
1. Can iSync be used for backups?  I'm not sure if I have iSync unless 
it is standard in Panther.
Well, Apple's blurbs seemed to say such things, but I think, when I 
read the fine print, it was for backing up to your .mac account.

2. Otherwise, has someone wrote a perl program to do this that I can 
run in cron.
Wasn't there a related thread here just this last week, including 
mention of either CpMac or ditto?

I'll shut up now.
--
Joel Rees
Opinions are like armpits.
We all have two, they all smell,
and we really don't want the other guy to get rid of his.


[non-perl] osx startup login items, was Re: LC_ALL for daemons

2004-04-30 Thread Chris Devers
On Fri, 30 Apr 2004, Sherm Pendley wrote:

 At system startup, items are sorted so that the ones that provide a
 given service are started before the ones that use or require it.

 Overall, I think it's a much more elegant system than the old
 numbered rc files scheme. That scheme always brings back unpleasant
 memories of having to renumber lines of BASIC.

Yes, it is a nice system.

Unfortunately, it seems like it's being deprecated.

I don't quite understand yet where things are going, but some of the
startup items in 10.3 have been rewritten in such a way that the service
is, when possible, not launched but primed such that that they're ready
to use on demand but they aren't taking up system resources when you
don't need them. So, for example, the Postfix mail daemon won't be
launched, but it will be set to respond to requests to send out mail on
an as needed basis.

You get faster boot times and a reduced average system load, while
getting higher latency for some services at run time. For a fast modern
machine, latency might not be a big deal, and the fast boot might be
more noticeable to most people than anything else. Still, it'll be nice
if you could tweak this stuff (it is, for example, still possible to
write an older-style Postfix startup routine that launches fully).

In any case, I don't think any of this stuff was present in Jaguar, and
it only shows up occasionally in Panther. The implementation of these
new startup scripts seems to look a bit more like old RC scripts, but
they still seem to do the nifty dependency tree stuff that OSX has been
using so far.

The current startup procedure isn't hard at all to learn -- all you need
is a /Library/foo directory, a /Library/foo shell script (or whatever
language program), and a /Library/foo/StartupParameters.plist config
file in either XML or NeXT plist format. Looking ahead though, it might
be worth tinkering with the new 10.3 startup routines, too...


***

But anyway, a question.

If Linux users want to use ssh-agent, they can hook it in to their
~/.xinitrc file to cause it to launch at X login time and to export some
environment variables to all processes started in the X session.

Where is the best place to poke this on OSX?

You can create a ~/.MacOSX/environment.plist file, but this will only
set variables, not launch programs (as far as I know). No help there.

Can you have a shell script launch as a login item? I've only been able
to get graphical applications to launch this way.

I've poked at SSH Agent.app, but it kept crashing...

Suggestions welcome :-)





-- 
Chris Devers


Re: [non-perl] osx startup login items, was Re: LC_ALL for daemons

2004-04-30 Thread Sherm Pendley
On Apr 30, 2004, at 9:29 PM, Chris Devers wrote:
I don't quite understand yet where things are going, but some of the
startup items in 10.3 have been rewritten in such a way that the 
service
is, when possible, not launched but primed such that that they're ready
to use on demand but they aren't taking up system resources when you
don't need them.
I thought they were using xinetd for that - if so, that's pretty 
standard.

If Linux users want to use ssh-agent, they can hook it in to their
~/.xinitrc file to cause it to launch at X login time and to export 
some
environment variables to all processes started in the X session.

Where is the best place to poke this on OSX?
You can create a ~/.MacOSX/environment.plist file, but this will only
set variables, not launch programs (as far as I know). No help there.
Ah, but setting variables is what you want to do. The SSH_ASKPASS 
environment variable points to a program that SSH, when it's not 
connected to a terminal, will launch to ask for a login and password on 
its behalf.

Have a look at Bill Bumgarner's SSHPassKey utility. It provides just 
such an app, and it can (if you want) also store SSH passwords on the 
keychain. It'll even poke the necessary variables into 
environment.plist for you.

http://www.codefab.com/unsupported/SSHPassKey_v1.1-1-README.html
sherm--


Re: backing up system

2004-04-30 Thread Joseph Alotta
On Apr 30, 2004, at 4:58 PM, Jerry LeVan wrote:
Yeah, but the person requesting advice say that he wanted the job
to run at an off time since it tied the machine up for 40 minutes...
It seems that with anacron, I would get into work bright and early, turn
on my machine and it would be useless for doing real work since it would
begin all the night jobs.
What if anacron had a catch up mode, that uses 1 second every 20 seconds
until all the back jobs were finished?
Joe.



Re: backing up system

2004-04-30 Thread Joseph Alotta
(I just tried, for grins, under 10.2.8, su-ing to an admin user, then 
sudo-ing a sh to get a root shell without logging in as root, but 
open-ing /Applications/AppleWorks 6 as the root user didn't seem to 
do anything other than opening the /Applications directory in a GUI 
window. open-ing /Applications/TextEdit.app as root runs TextEdit, 
but the process is owned by the user I'm logged in as. sudoing the 
open directly from the admin user yields complaints about not being 
able to map display interlocks or open default connections, etc. 
That's not Panther, of course.)
I couldn't sudo and open Silverkeeper.app either.  Besides it is too 
resource intensive.  I wouldn't mind something slower, but quieter in 
the background.


1. Can iSync be used for backups?  I'm not sure if I have iSync 
unless it is standard in Panther.
Well, Apple's blurbs seemed to say such things, but I think, when I 
read the fine print, it was for backing up to your .mac account.
They have an app called Backup.app, but it insists on you having a .mac 
account and being online.  I don't think it is worth paying a monthly 
fee for this.

Joe.



Re: Access External Hard Drive - Local and Network

2004-04-30 Thread Chris Devers
On Fri, 30 Apr 2004, Mark Wheeler wrote:

 [snip] In the Volumes directory, it lists the following as the mounted
 folder:

 PRINCETON;DELLSERVER

 How do I get into the server? The pathway I tried is:

 /Volumes/PRINCETON;DELLSERVER/

 That didn't work.

These kinds of things are *always* easier for people to debug when we
can actually see, at a minimum, a sample of the code in question. In
this case, seeing a directory listing wouldn't hurt either:

   $ ls -l /Volumes/

At a guess, the semi-colon may need to be escaped with a backslash.
These shell commands try to show why:

$ ls -l PR*
ls: PR*: No such file or directory
$ touch PRINCETON;DELLSERVER
bash: DELLSERVER: command not found
$ ls -l PR*
-rw-r--r--  1 cdevers  admin0 Apr 30 23:44 PRINCETON
$ touch PRINCETON\;DELLSERVER
$ ls -l PR*
-rw-r--r--  1 cdevers  admin0 Apr 30 23:44 PRINCETON
-rw-r--r--  1 cdevers  admin0 Apr 30 23:44 PRINCETON;DELLSERVER
$ rm PR*
$ touch 'PRINCETON;DELLSERVER'
$ ls -l PR*
-rw-r--r--  1 cdevers  admin0 Apr 30 23:45 PRINCETON;DELLSERVER
$ rm PR*
$ touch PRINCETON;DELLSERVER
$ ls -l PR*
-rw-r--r--  1 cdevers  admin0 Apr 30 23:46 PRINCETON;DELLSERVER
$ rm PR*
$ touch PRINCETON\;DELLSERVER
$ ls -l PR*
-rw-r--r--  1 cdevers  admin0 Apr 30 23:46 PRINCETON\;DELLSERVER

See what's going on? With a backslash or quotes, I'm able to create the
file. With no backslash, I create a file with everything up until the
semi-colon as the name; with quotes and a backslash the file ends up
having the literal backslash character.

So, it's hard to say what you need to do without knowing what your code
looks like, but bear in mind that Perl's rules for this kind of thing
will be similar to what the shell is doing here. Just note that you
probably *must* quote the string, or Perl will treat the text as a
bareword and throw ugly warnings  errors at you, so you need some way
of balancing quotes  backslashes appropriately. Make sense?


It may be easier for you to just symlink the semi-colon version of the
name to an easier equivalent:

$ ln -s /Volumes/PRINCETON\;DELLSERVER /Volumes/dellserver

And things should be much easier in Perl-land after that...



-- 
Chris Devers


Re: Access External Hard Drive - Local and Network

2004-04-30 Thread Sherm Pendley
On Apr 30, 2004, at 11:54 PM, Chris Devers wrote:
So, it's hard to say what you need to do without knowing what your code
looks like, but bear in mind that Perl's rules for this kind of thing
will be similar to what the shell is doing here.
Not really. The semicolon is the end-of-statement marker in both shell 
and Perl. What is happening when you enter touch FOO;BAR at a shell 
prompt is that the shell interprets it as two commands - touch FOO 
and BAR. The first works, and touches a file named FOO; the second 
fails because BAR isn't a valid command or script.

Perl scripts won't have this problem, because strings are always quoted 
in Perl, and (barring eval()) they're treated as data, not Perl code. 
Built-in Perl functions like rename(), unlink(), and open() don't even 
blink at semicolons in path names.

On the other hand, if you're building up a shell command and executing 
it with back-ticks, system(), or the like, then you *do* need to be 
aware of how the that shell will react to semicolons in the command. 
Your Perl script will need to escape them with backslashes as needed by 
the shell.

So, assuming you get $volname from a call to readdir(), you'd need to 
do something like this before passing it to a system():

$volname =~ s/;/\\;/g;
Note the doubled backslashes - that causes Perl to insert a literal 
backslash. A single slash would cause it to interpret \; as an escape 
sequence; since it has no meaning as an escape sequence, it evaluates 
to a plain ';'.

sherm--


Re: Access External Hard Drive - Local and Network

2004-04-30 Thread Mark Wheeler
Hi,
Thanks for the help. Below is the code and (although from memory) a  
listing of the /Volumes/ directory.

/Volumes/:
10 GB Firewire Drive
eDrive
PRINCETON;DELLSERVER
PRINCETON;DELLSERVER-1
PRINCETON;DELLSERVER-2
PRINCETON;DELLSERVER-3
And the perl code:
 
-
#!/usr/bin/perl -w

use strict;
use File::Copy;
my @dbname = (file 1.dat,file 2.dat,file 3.dat,file 4.dat);
my @dbpath = (directory 1,directory 2/subdirectory  
2,SharedDocs,SharedDocs);
my $dirto = /Volumes/10GB Firewire Drive/;
my $dirfrom = /Volumes/PRICETON;DELLSERVER/;
my ($backup, $i);

my $timetest = time;
my ($sec,$min,$hour,$mday,$mon,$year,$wday) = localtime($timetest);
$year = substr(1900 + $year,2,2);
$mon++;
if ($mon   10) { $mon  = 0$mon;  }
if ($mday  10) { $mday = 0$mday; }
my $date = $mon-$mday-$year;
for ($i=0; $i=$#dbname; $i++) {
  $backup = $dbname[$i].-$date.bak;
  copy ($dirfrom$dbpath[$i]/$dbname[$i], $dirto$backup) or warn  
Can't copy file $dirfrom$dbpath[$i]/$dbname[$i] to $dirto$backup -  
$!\n;
  if (-e $dirto$backup) {
  print $dbname[$i] backed up.\n;
  } else {
  print $dbname[$i] NOT backed up!\n;
  }
}

print Backup Complete.\n;
 


I hope this makes things more clear.
Thanks,
Mark
On Apr 30, 2004, at 8:54 PM, Chris Devers wrote:
On Fri, 30 Apr 2004, Mark Wheeler wrote:
[snip] In the Volumes directory, it lists the following as the mounted
folder:
PRINCETON;DELLSERVER
How do I get into the server? The pathway I tried is:
/Volumes/PRINCETON;DELLSERVER/
That didn't work.
These kinds of things are *always* easier for people to debug when we
can actually see, at a minimum, a sample of the code in question. In
this case, seeing a directory listing wouldn't hurt either:
   $ ls -l /Volumes/
At a guess, the semi-colon may need to be escaped with a backslash.
These shell commands try to show why:
$ ls -l PR*
ls: PR*: No such file or directory
$ touch PRINCETON;DELLSERVER
bash: DELLSERVER: command not found
$ ls -l PR*
-rw-r--r--  1 cdevers  admin0 Apr 30 23:44 PRINCETON
$ touch PRINCETON\;DELLSERVER
$ ls -l PR*
-rw-r--r--  1 cdevers  admin0 Apr 30 23:44 PRINCETON
-rw-r--r--  1 cdevers  admin0 Apr 30 23:44 PRINCETON;DELLSERVER
$ rm PR*
$ touch 'PRINCETON;DELLSERVER'
$ ls -l PR*
-rw-r--r--  1 cdevers  admin0 Apr 30 23:45 PRINCETON;DELLSERVER
$ rm PR*
$ touch PRINCETON;DELLSERVER
$ ls -l PR*
-rw-r--r--  1 cdevers  admin0 Apr 30 23:46 PRINCETON;DELLSERVER
$ rm PR*
$ touch PRINCETON\;DELLSERVER
$ ls -l PR*
-rw-r--r--  1 cdevers  admin0 Apr 30 23:46  
PRINCETON\;DELLSERVER

See what's going on? With a backslash or quotes, I'm able to create the
file. With no backslash, I create a file with everything up until the
semi-colon as the name; with quotes and a backslash the file ends up
having the literal backslash character.
So, it's hard to say what you need to do without knowing what your code
looks like, but bear in mind that Perl's rules for this kind of thing
will be similar to what the shell is doing here. Just note that you
probably *must* quote the string, or Perl will treat the text as a
bareword and throw ugly warnings  errors at you, so you need some way
of balancing quotes  backslashes appropriately. Make sense?
It may be easier for you to just symlink the semi-colon version of the
name to an easier equivalent:
$ ln -s /Volumes/PRINCETON\;DELLSERVER /Volumes/dellserver
And things should be much easier in Perl-land after that...

--
Chris Devers



Re: backing up system

2004-04-30 Thread Chris Nandor
In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Joseph Alotta) wrote:

  1. Can iSync be used for backups?  I'm not sure if I have iSync 
  unless it is standard in Panther.
 
  Well, Apple's blurbs seemed to say such things, but I think, when I 
  read the fine print, it was for backing up to your .mac account.
 
 They have an app called Backup.app, but it insists on you having a .mac 
 account and being online.  I don't think it is worth paying a monthly 
 fee for this.

I believe Backup.app is only available to .Mac subscribers, but the app 
itself does not require a .Mac account, or being online, any longer.  You 
can back up to any local volume (including shared volumes over the network).

-- 
Chris Nandor  [EMAIL PROTECTED]http://pudge.net/
Open Source Development Network[EMAIL PROTECTED] http://osdn.com/


Re: Access External Hard Drive - Local and Network

2004-04-30 Thread Sherm Pendley
On May 1, 2004, at 1:08 AM, Mark Wheeler wrote:
PRINCETON;DELLSERVER

my $dirfrom = /Volumes/PRICETON;DELLSERVER/;
Is that code copy-n-pasted? If it is, it's missing an 'N'. ;-)
sherm--


Re: Access External Hard Drive - Local and Network

2004-04-30 Thread Mark Wheeler
Hi Sherm,
Yes, it's copy-n-pasted! I can't believe I missed that! With that 
changed, does everything in the script look in order to function 
correctly? Or do I need to change it to 
/Volumes/PRINCETON\;DELLSERVER/;

Thanks,
Mark
On Apr 30, 2004, at 10:30 PM, Sherm Pendley wrote:
On May 1, 2004, at 1:08 AM, Mark Wheeler wrote:
PRINCETON;DELLSERVER

my $dirfrom = /Volumes/PRICETON;DELLSERVER/;
Is that code copy-n-pasted? If it is, it's missing an 'N'. ;-)
sherm--



Re: Access External Hard Drive - Local and Network

2004-04-30 Thread Sherm Pendley
On May 1, 2004, at 1:37 AM, Mark Wheeler wrote:
With that changed, does everything in the script look in order to 
function correctly? Or do I need to change it to 
/Volumes/PRINCETON\;DELLSERVER/;
No, you're using Perl's built-in copy() function, so the back-slash 
isn't needed. It's only needed if you're calling an external tool such 
as cp or CpMac, for example, and passing the file name.

Note that, as it stands, the backslash in the source code isn't 
actually making it into the string. The string is double-quoted, so \; 
is interpreted as an escape sequence. Since \; isn't a valid escape 
sequence, the backslash is ignored and the result is just a semicolon. 
To insert a literal backslash into a double-quoted string, you need to 
double it - \\.

sherm--