Shell versions affecting find?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell versions affecting find?
# 1  
Old 02-23-2009
Question Shell versions affecting find?

Hi all,

I just spent 30hours writing a script (my first) that makes extensive use of the find command on my mac os x terminal and which was meant to be run as a cron job on my server. The script is an automated backup system for a bunch of source control repositories. On the mac it works perfectly, but on the server, it fails miserably.


An example of a line of code that fails on the server:
Code:
modified=`stat -f "%Sm" -t "%c" $repoPath/$file`


Have I just received my first painful lesson that Linux is not the same as Unix or could I be doing something wrong at a more basic level?
# 2  
Old 02-23-2009
Hi, cpower.

Welcome to the forums.

Thanks for using code markups, that helps with readability.

Please explain more about how your command fails. It is also useful if you tell us what version of OS X you are using as well as the distribution of Linux, what shell you are referring to, and perhaps the exact text of the error message you are receiving (if any) -- the Sherlock Holmeses here usually need evidence to solve mysteries Smilie ... cheers, drl
# 3  
Old 02-24-2009
Thanks for the quick reply. Since my first post, I re-wrote the whole script following the man pages on my server rather than on the mac and it works perfectly.

What I'm still lost on however is the difference between the bash flavors. I understand that Mac OSX 10 is BSD unix based and my server is running a GNU/Linux bash, but other than finding different entries for certain man pages, I cant find any other references to shell scripts not being compatable between the two systems. Even more confusing for me is that the environment was set to the Bourne Shell. Shouldn't this be 100% compatible?

The bash versions as reported by each bash:
Macbook pro:
Code:
/bin/bash --version
GNU bash, version 3.2.17(1)-release (i386-apple-darwin9.0)
Copyright (C) 2005 Free Software Foundation, Inc.

Media temple gridserver:
Code:
/bin/bash --version
GNU bash, version 2.05b.0(1)-release (i386-pc-linux-gnu)
Copyright (C) 2002 Free Software Foundation, Inc.

# 4  
Old 03-01-2009
Bump..?
# 5  
Old 03-01-2009
Hi.

There will be some feature differences between versions of bash. However, if you are beginning learning Linux or BSD, those will be unlikely to bite you (famous last words).

I think you are far more likely to run into trouble with the gross and subtle differences in the commands of the two systems.

Perhaps something long the lines of BSD For Linux Users :: Intro may be useful ... cheers, drl
# 6  
Old 03-01-2009
Good article - I'll have a read. Thanks.
# 7  
Old 03-01-2009
Quote:
Originally Posted by cpower
gridserver:
Code:
/bin/bash --version
GNU bash, version 2.05b.0(1)-release (i386-pc-linux-gnu)
Copyright (C) 2002 Free Software Foundation, Inc.


That's a very old version of bash.

When writing scripts, especially those that must run in more than one environment, use only POSIX-compliant syntax and standard commands. Some commands, like stat, come in different versions with different options on different systems (and many do not even have such a command).
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Copy files without affecting the running process

Hi Experts, I would like to know in Linux any command which will replace a file without affecting the running process. I tried the mv command bug the running process is not taking the new file. Any rsync option is available like this for not affecting the current process. Thanks in... (7 Replies)
Discussion started by: ThobiasVakayil
7 Replies

2. Shell Programming and Scripting

Help with korn shell script to get the latest file versions in a directory

I want to write a korn shell script to get the latest three versions for a file in the directory having lot of files with various versions (files with prefix as same but time stamp as suffix) and compress it and at the same time have to remove the remaining versions of the file (other than latest... (4 Replies)
Discussion started by: maheshbabu
4 Replies

3. Shell Programming and Scripting

not del a file not affecting other permissions

i was faced by a question from a friend. i found it very tricky. all my months of learning unix i never can figure it out still. heres the question he faced me with. wondering if you all can help me figure a solution. ill let him know the forums helped me out :D What command would you use... (10 Replies)
Discussion started by: sunny231
10 Replies

4. Shell Programming and Scripting

shell script preserving last 2 versions of files

I need some help with the logic and syntax for a shell script (ksh) that will search a directory and look for similar files and save only the last two versions. The version number is in the file name. However, the files are of varying name lengths and may have 1 or many files, with no limit to... (6 Replies)
Discussion started by: synergy_texas
6 Replies

5. UNIX for Advanced & Expert Users

RCS - Find difference between 2 different versions of a file

Hi, I have a c file in my repository. We are using RCS(Revision Control System) to control and manage the versions. I need to find 1. Difference between the current version with a different version 2. Difference between any two different versions of a file. Ex Difference between 1.14 and... (1 Reply)
Discussion started by: kelangovan
1 Replies

6. Shell Programming and Scripting

Command to find how many disk arrays and versions

Hello, Can you tell me a command to tell how many disk arrays are installed in the system, their RAID types and versions. I am working on Solaris 9. Thanks very much in advance. Mohammed (1 Reply)
Discussion started by: Mohammed
1 Replies

7. Shell Programming and Scripting

How to manage multiple versions of a set of shell and SQL script utilities

Hi all --- I have the need to manage multiple versions of a set of utility scripts -- both shell and SQL and other .dat files. I am wondering if anyone out there knows of a good way to "PATH" to SQL and text files in a way similar to how PATH facilitates finding executables in a pre-specified... (2 Replies)
Discussion started by: DennisB
2 Replies
Login or Register to Ask a Question