1

I have this test sh script that I can run on my computer that is supposed to produce nothing as output if everything works. I've used scp to transfer everything in the folder I'm working in to a remote server and when I run it on the remote server I get errors like

egrep: Unmatched ) or \)
egrep: Unmatched ) or \)
./script.sh: line 229: ./helperScripts/script2.pl: No such file or directory

I didn't get these errors on my computer and when I check to see it script2.pl is in helperScripts it's in there

When i run sh -version in the remote server I get

GNU bash, version 4.1.2(1)-release (i686-redhat-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

When I run sh -version on my computers terminal I get

GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)
Copyright (C) 2007 Free Software Foundation, Inc.

I don't know if this matters. Does anyone know what I can do, I'd rather not have to rewrite things in my script because I've been trying to do that and it appears that more problems continue to come up when I make the new ones

closed as unclear what you're asking by Gilles, Jeff Schaller, Eric Renouf, mdpc, Anthon Sep 30 '16 at 5:27

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    You don't really provide the details needed to help. For example, what egrep versions are involved and what does the lines in the script look like? What does the directory structure look like; are really the script2.pl in the same place relative to where you run the script in both cases? How more exactly do you invoke the command in both cases? – Göran Uddeborg Sep 29 '16 at 20:42
1

It doesn't need to matter, but yes, it can matter depending how you write. And, you didn't provide the script for anyone to point out how to write for any Bourne shell. If you would rather just have versions of BASH that are more compatible with one another...

Install Homebrew on your Mac using Terminal.app or iTerm2.app. And with Homebrew, install BASH (brew install bash). Then change your shell on Mac: chsh -s /usr/local/bin/bash. Log out. Log in. Today, this gets you BASH 4.4 on macOS/OS X, which is far more compatible with the other BASH versions you that have. This won't save some rewriting of current scripts, but will almost certainly eliminate the problems for new scripts.

Scripts local to the Mac could also use #!/usr/local/bin/bash without changing your shell.

You may also need to install Xcode to compile software from Homebrew. If you have not done it after installing Xcode (from the App Store), install Xcode's Command Line Tools with xcode-select --install.

Not the answer you're looking for? Browse other questions tagged or ask your own question.