LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 06-01-2005, 08:57 AM   #1
mariusak
LQ Newbie
 
Registered: Feb 2004
Distribution: Debian 3.0
Posts: 23

Rep: Reputation: 15
Question Trigger linux command by windows batch file?


Still struggeling with my backup system (samba in windows workgroup..)

Anyway, since, when you copy a file to samba from windows, the modification date of the file is not updated (modification date IS updated when copying a file from windows to windows).

I'm using xcopy to compare files and then copy the ones that are newer on source.

Xcopy compares MODIFICATION date, and therefore the system don't work (it copies all the files every time you run the windows backup batch file).

If I manually logon to my linux box, use this command find . -exec touch {} \; in the backup folder, the modification date is updated on all files.

Is it in any way possible to have the touch-command (which is slow though, but I cant come up with another solution) on every file which is copied to samba, or to trigger the find . -exec touch {} \; by the windows batch file when backup is completed?

Any help or hints will be highly apprechiated!

Have a nice afternoon.. (GTM +1) :-)

-Marius
 
Old 06-01-2005, 09:52 AM   #2
kees-jan
Member
 
Registered: Sep 2004
Distribution: Debian, Ubuntu, BeatrIX, OpenWRT
Posts: 273

Rep: Reputation: 30
Hi,

I do not yet understand your problem. If copying works correctly, then after copy both source and destination have the same timestamp. So xcopy should be able to determine which files are newer, since it will have a newer timestamp. Also, I've read the help of xcopy, and I can't find the exact option you are using, because apparently it's not in the help.

Triggering linux commands from a batchfile, I've done a lot. Take a look at cygwin. It contains a lot of unix tools ported to windows. Among those is ssh. Using ssh, you can execute a script on the linux server, triggered from a batch file. If you use public key authentication, you won't even have to type your password.

Also, the command you gave can be speeded up. You'll find that
Code:
find . -print0 | xargs -0 touch
is much faster at doing the same.

Groetjes,

Kees-Jan
 
Old 06-01-2005, 10:23 AM   #3
mariusak
LQ Newbie
 
Registered: Feb 2004
Distribution: Debian 3.0
Posts: 23

Original Poster
Rep: Reputation: 15
Hi!

I will try to express myself clearer (Just try to avoid to write a too long and detailed "first" post, since then too many tend to not bother starting to read it at all..)

Okay, first of all xcopy:
I use the option /D:m-d-y Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destiantion time.

When syncing to a native windows drive this works perfectly. But, when syncing to samba, this does not work. The CHANGED attribute on the files on linux are updated to the time of copy, but the MODIFIED date is the same as the MODIFIED date on the source file. The problem is that xcopy needs to know if the file on source has been updated since last copy to destination. Xcopy compares MODIFIED date on source and dest, and because both are the same it copies the file again (I guess to be on the safe side?). If I update the modified attribute on the linux file manually (touch option -m), it works as I would like it to.

So either I have to tell xcopy to compare change date and not modification date (not possible), or I have to tell linux to change the MODIFIED attribute in a way or another. My quest is to find out how to do this..?

I have really no clue on how I should approach thisissue, so I would apprechiate any help!
Hope I managed to explain more or less what I mean now..

I will look into cygwin and see what I can do.. Remeber, it has to work an a standar windows installation (also Home Edition), or at least it has to be easy to install on the clients..

I looked into cygwig briefly. I dont think this is what I want to use. Or am I wrong?

-Marius

Last edited by mariusak; 06-01-2005 at 12:35 PM.
 
Old 06-01-2005, 03:01 PM   #4
mariusak
LQ Newbie
 
Registered: Feb 2004
Distribution: Debian 3.0
Posts: 23

Original Poster
Rep: Reputation: 15
My workaround...

I'm going to do the following since I bloody **** cannot find any other solution:

(The batch files for each client are created automatically by a small applet of mine..)

When the backup is complete, the following command is executed: iexplore http://BACKUPSERVER/backupfinished.php?usr=NAMEOFUSER Name of user is also the name of it's home folder.

Then in backupfinished.php on the server, I use
PHP Code:
shell_exec 
to execute the command find /home/$urs/. -print0 | xargs -0 touch

I add the apache user to my backup user group and it should work.. but really, there must be a different way of doing it!

There are of course some security issues when doing it this way, but it is an internal server which is not exposed to the internet (apache only allows our internal IPs).

-Marius

Last edited by mariusak; 06-01-2005 at 03:05 PM.
 
Old 06-03-2005, 04:33 AM   #5
mariusak
LQ Newbie
 
Registered: Feb 2004
Distribution: Debian 3.0
Posts: 23

Original Poster
Rep: Reputation: 15
For some reason this command:

Code:
find . -print0 | xargs -0 touch
..does not touch all my files. Some get excluded.

Code:
find . -exec touch {} \;
is, as said, much slower, but touches all files.

-Marius
 
Old 06-03-2005, 04:39 AM   #6
kees-jan
Member
 
Registered: Sep 2004
Distribution: Debian, Ubuntu, BeatrIX, OpenWRT
Posts: 273

Rep: Reputation: 30
That's very strange.

Which files get skipped??

Groetjes,

Kees-Jan
 
Old 06-03-2005, 05:15 AM   #7
mariusak
LQ Newbie
 
Registered: Feb 2004
Distribution: Debian 3.0
Posts: 23

Original Poster
Rep: Reputation: 15
I know, I was confused as well..

Did some more testing after I posted, and now it works again. I have been playing around with the permissions of some files (umask trouble), it did not work properly because I had not given the user executing the touch command the proper rights to some of the files.. Does make sense, doesn't it ?
(I executed the find . -exec touch {} \; as root, and then it obviously worked. Stupid me.)

Anyway, I do have som major umask trouble, I posted a thread in the newbie forum but did not get much response..

If anybody wants to have a look, feel free to!

http://www.linuxquestions.org/questi...hreadid=329529

-Marius

Last edited by mariusak; 06-03-2005 at 05:16 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
call program on linux box from windows batch file naijaguy Programming 5 08-14-2004 11:12 AM
Linux box calling a batch script on a windows box to run? Is it possible? joelhop Programming 8 05-17-2004 04:49 PM
Can I get an incoming email to trigger a script file? davee Linux - General 2 10-16-2003 02:45 PM
backing up linux with a batch file... RaVensRealm Linux - Newbie 6 04-16-2003 08:59 PM
Like MS-DOS batch file but for Linux? rverlander Programming 2 06-23-2002 02:51 PM


All times are GMT -5. The time now is 11:20 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration