Equivalent of a PC batch file needed

fixxxer

Registered
Hi there,

I am running two Xservers, one of them, our primary open directory server also hosts a roaming profile folder. I need to create some type of script or program that would allow me to make a daily copy of that folder on the second Xserver.

In the PC world, this would be easily done through a batch file, and simply setting it up as a scheduled task, but I am not sure how to go about it in a MAC environment.

Any suggestions?

Thanks.
 
Sadly, unlike Windoze, MacOS X only comes (built-in) with several (plus) scripting capabilities:
Applescript, AppleScript Studio, Automator ('Tiger' 10.4.x), bash, csh, ksh, Perl, php, Python, Ruby, tcsh, tclsh, and zsh. To the best of my knowledge ...; and, I may have missed some others.

See 'Google' and 'Open Source on MacOS X' for most of the above MacOS X scripting abilities.
For AppleScript information click here; for AppleScript, AppleScript Studio, and Automator - Programming Guides click here.

Once you create the MacOS X script - you have the option of simply setting it up as a scheduled task via 'cron's 'crontab'.
 
texanpenguin said:
10.4 uses launchd I think for scheduled events (rather than cron)
Well, not quite. Launchd is the "original" process, in that way that 'init' is for Linux. In that regard it's the parent of all other process on the system. So it starts cron and uses "periodic" which is an interface to cron, for Apple's scheduled jobs. But it's still cron that's responsible for launching scheduled commands.
 
If you just want to do a daily copy, get a backup tool like Carbon Copy Cloner or Retrospect... They both can be scheduled to do this very basic task.
 
I know this is old, but I cannot resist...

Sadly, unlike Windoze, MacOS X only comes (built-in) with several (plus) scripting capabilities:
Applescript, AppleScript Studio, Automator ('Tiger' 10.4.x), bash, csh, ksh, Perl, php, Python, Ruby, tcsh, tclsh, and zsh. To the best of my knowledge ...; and, I may have missed some others.

Why provide 13+ scripts when one can do the job? I know each one of the ones you have listed have different purposes, but I don't think he was asking for built in scripts for legacy code or web development.

Built-in with 13+ scripts, and people say Windows is bloated. Ha! Give me a break...
 
I believe barhar was being facetious with his comment... he was merely explaining that there are more than a handful of ways to script something with Mac OS X -- unlike Windows, which includes basically one way to script. barhar's point was that, yes, one script would do the job -- but you have a bunch of options in choosing which scripting language to use to do that job for you. Some people know Ruby inside and out -- others, like myself, would opt for Perl or php. That means that if someone is versed in scripting, the tool they would want to use is already included in Mac OS X -- no need to go searching or installing anything.

Not to mention in Mac OS X, you can combine those scripting languages to achieve things that the Windows batch file could only dream of -- imagine a php program that parses text, then passes that text on to a Perl program for severe and powerful regex processing. While it may seem overly complicated to some, it's actually very elegant and powerful, and there is extremely little that can't be done with one or more of those languages. In addition, a lot of those languages are good for web-based scripting, while others are great for local, command-line scripting.

Also bear in mind that each of those scripting/programming languages is very small -- hardly considered "bloat."

There are also several, small, freely-available programs that will help a novice set up a scheduled task using Mac OS X's built-in scheduler (either cron or launchd). For those that are experienced with UNIX-style scheduling, it's a no-brainer to set up a script to run every hour or whatever. For novices, there are programs that allow you to schedule tasks with a simple GUI.

Was your point that Windows is much simpler? Or more powerful? Or "less bloated" (which it is not)? Maybe I'm missing the point of your post...
 
The point of my post was to point out what I found comical.

I don't understand what you mean by "basically one way" to script, or do not agree if it is as literal as it sounds. Windows comes with more than one built-in script: batch, VBScript, VBA, and JScript to name a few.
 
Are those technologies "built in" to Windows, or do they require separate downloads? As far as I know, VBScript and JScript require the .NET framework, the most recent version not being included with Windows XP. VBA also requires a download of some or all of Visual Studio, no?

By "one way to script" in Windows, I was referring to, out-of-the-box, Windows pretty much allows you to script with ancient DOS batch files (the new PowerShell is nice, but is not "built-in" to Windows and requires a separate download). Other scripting ways under Windows require portions of Visual Studio.
 
Since Windows Vista, yes they are. You are correct that they require the .Net Framework, but the .Net Framework comes built-in with Vista. While Visual Studio's serves as an IDE for VBA, it is not required to write and use VBA script.

This also should not go towards a comparison of Visual Studios and the built-in scripting environments of a Mac. A Mac does provide a great simple way to write script "out-of-the-box," but it is in no way comparable to the features and capabilites of Visual Studios. The addition of Visual Studios Express Edition with Windows would go a long for Windows. It is not built-in, so all that it would enable you to do does not belong in this discussion... but, I do have a question for you regarding that. Would it be better for Windows to include yet another component to their OS so that it is "built-in," or is the fact that you can download the Express Edition for free so that individual users choose what they want better?
 
Since Windows Vista, yes they are. You are correct that they require the .Net Framework, but the .Net Framework comes built-in with Vista. While Visual Studio's serves as an IDE for VBA, it is not required to write and use VBA script.
Ah, I see. My experience is great with XP -- haven't had much time on a Vista machine, though, so thanks for the info. Of course, in setting up a new XP machine, Visual Studio and .NET are the first and foremost things to get installed. So, I guess, my out-of-the-box Windows machines do include several ways to "script" (I use the term "script" loosely to mean, basically, "writing code," although some of the code that is written is more "programming applications" than "writing scripts.")

This also should not go towards a comparison of Visual Studios and the built-in scripting environments of a Mac. A Mac does provide a great simple way to write script "out-of-the-box," but it is in no way comparable to the features and capabilites of Visual Studios. The addition of Visual Studios Express Edition with Windows would go a long for Windows. It is not built-in, so all that it would enable you to do does not belong in this discussion...
True, true. For Mac OS X to reach the power of Visual Studio, one would need a better development environment than the commnd-line or AppleScript -- something along the lines of XCode and knowledge of Cocoa/Objective-C.

...but, I do have a question for you regarding that. Would it be better for Windows to include yet another component to their OS so that it is "built-in," or is the fact that you can download the Express Edition for free so that individual users choose what they want better?
I guess this is all personal preference -- in Mac OS X, as I stated, those languages take up very little space... a few hundred megabytes to a maximum of a gigabyte for all of them together. The reason is probably because they're command-line based and have no need to include a GUI, which is a very large portion of the size of an IDE.

Still, it's worth comparing that Visual Studio and the .NET framework are quite large -- Visual Studio being several gigabytes for the complete package (C#, C++, VB, etc.).

Part of the reason that Mac OS X includes these technologies is that they are almost inherent to a UNIX distribution. While not included in all distributions, they are key languages in doing useful things in the command-line. Windows, on the other hand, is a much more GUI-oriented operating system, with a "shell" that is decades old. But now we're getting into backward-compatibility issues...

I dunno. It can be argued one way or another. Mac OS X includes a ton of useful scripting and programming languages out-of-the-box, but require programming knowledge to use. I could say that a newcomer that is not familiar with programming and has little command-line experience couldn't even begin to use Perl or Ruby. This is not so with Visual Basic -- a newcomer with little programming experience or command-line experience can take up Visual Basic in a few days and be "productive" with it to an extent.
 
Back
Top