LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Other *NIX
User Name
Password
Other *NIX This forum is for the discussion of any UNIX platform that does not have its own forum. Examples would include HP-UX, IRIX, Darwin, Tru64 and OS X.

Notices


Reply
  Search this Thread
Old 06-25-2016, 05:03 PM   #1
wagscat123
Member
 
Registered: Jan 2009
Location: Maryland-Pennsylvania border, USA
Distribution: openSUSE 15.2/15.3, Tumbleweed, Kubuntu 18.04/21.04, macOS 10.15, antiX 19, and Linux Mint 19.3
Posts: 860
Blog Entries: 45

Rep: Reputation: 120Reputation: 120
Running Bash Shell Script for Linux on OS X variable confusion


Hi all,

I'm using a CTX script from https://psd-repo.uchicago.edu/kite-l...go_asp_scripts. I was forewarned that they were tested under Linux and may or may not work under OS X, although in this situation I must run OS X. When I run ctxedr2lev1eo.sh with a properl input file, I get

Code:
lynnes-iMac:tc_trunk_theirs0 CSSTinterns$ ctxedr2lev1eo.sh list
/Users/CSSTinterns/isis-workspace/mars-proj/theirs/ctxedr2lev1eo.sh: line 41: [[!: command not found
/Users/CSSTinterns/isis-workspace/mars-proj/theirs/ctxedr2lev1eo.sh: line 41: [[!: command not found
/Users/CSSTinterns/isis-workspace/mars-proj/theirs/ctxedr2lev1eo.sh: line 41: [[!: command not found
/Users/CSSTinterns/isis-workspace/mars-proj/theirs/ctxedr2lev1eo.sh: line 41: [[!: command not found
Start ctxedr2lev1eo.sh Sat Jun 25 17:49:03 EDT 2016
first. However, when I copy and paste all of the code up to and including line 41, then run this smaller script alone in isolation on OS X with the same input file, I do not get this same error. Why could this be?

Here's a the script snipped I'm running in isolation:

Code:
lynnes-iMac:test_compat CSSTinterns$ cat linuxornot0.sh 
# Just a simple function to print a usage message
print_usage (){
echo ""
echo "Usage: $0 <productIDs.lis>"
echo " Where <productIDs.lis> is a file containing a list of the IDs of the CTX products to be processed."
echo " Product IDs belonging to a stereopair must be listed sequentially."
echo " The script will search for CTX EDRs in the current directory before processing with ISIS."
}

### Check for sane commandline arguments

if [[ $# != 1 ]] || [[ "$1" = "-"* ]]; then
  # print usage message and exit
  print_usage
  exit 0
else 
  p=$1
fi
lynnes-iMac:test_compat CSSTinterns$
with "if [[ $# != 1 ]] || [[ "$1" = "-"* ]]; then" being the line that acts up in the larger program.

Spent a while on this, but have more time to figure it out. Any ideas?

Last edited by wagscat123; 06-25-2016 at 08:20 PM.
 
Old 06-25-2016, 07:24 PM   #2
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
Unless I'm missing something line 41 is the following:
Code:
	if [[! -s $i.img ]] || [[! -s $i.IMG ]]; then
From https://psd-repo.uchicago.edu/kite-l...xedr2lev1eo.sh

Try putting a space before the exclamation points:
Code:
	if [[ ! -s $i.img ]] || [[ ! -s $i.IMG ]]; then
 
1 members found this post helpful.
Old 06-25-2016, 08:01 PM   #3
wagscat123
Member
 
Registered: Jan 2009
Location: Maryland-Pennsylvania border, USA
Distribution: openSUSE 15.2/15.3, Tumbleweed, Kubuntu 18.04/21.04, macOS 10.15, antiX 19, and Linux Mint 19.3
Posts: 860

Original Poster
Blog Entries: 45

Rep: Reputation: 120Reputation: 120
Thanks for your reply - I tried adding that space on Line 41 a try, but still got the same error.

Last edited by wagscat123; 06-25-2016 at 08:03 PM.
 
Old 06-25-2016, 08:39 PM   #4
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
Sorry, maybe it is a OS X thing then. On my Debian box my simple test errors without the spaces:
Code:
$ if [[! -s some.img ]] || [[! -s some.IMG ]]; then echo "warning"; fi
bash: [[!: command not found
bash: [[!: command not found
It works with spaces:
Code:
$ if [[ ! -s some.img ]] || [[ ! -s some.IMG ]]; then echo "warning"; fi
warning
 
Old 06-26-2016, 12:48 PM   #5
wagscat123
Member
 
Registered: Jan 2009
Location: Maryland-Pennsylvania border, USA
Distribution: openSUSE 15.2/15.3, Tumbleweed, Kubuntu 18.04/21.04, macOS 10.15, antiX 19, and Linux Mint 19.3
Posts: 860

Original Poster
Blog Entries: 45

Rep: Reputation: 120Reputation: 120
I didn't look closely enough to realize that I had to add a space before both exclamation points. That did the trick and got me past this one error for now. Many thanks! I may be back later if I run into another issue.
 
  


Reply



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
[SOLVED] Bash Shell Script - Store a variable as a string not an integer RML1992 Linux - General 8 09-12-2012 09:19 AM
How to use a variable to index an array in Bash shell script? anotheremily Programming 3 06-22-2012 09:46 PM
[SOLVED] bash - script not see environment variable running under sudo jfjh201 Linux - Newbie 1 06-16-2012 07:23 PM
In BASH shell, how do I export a variable from a script. MichaelG67 Linux - Software 2 06-24-2010 01:03 PM
Bash/Shell: Problem using a variable in a script redvivi Linux - General 8 08-21-2008 02:02 PM

LinuxQuestions.org > Forums > Other *NIX Forums > Other *NIX

All times are GMT -5. The time now is 07:43 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration