简体   繁体   中英

Throw error when I run in my shell script but run successfully in terminal console

I am working on MacOS. Why can I run my command in the console and cannot run it in the shell?

The command is :

/usr/local/fsl/bin/fast "test.nii.gz"

The /usr/local/fsl/bin/fast is a software to preprocess the neuroimage.The official documentation is at FAST docs .

This is my shell script:

#!/bin/sh
/usr/local/fsl/bin/fast "test.nii.gz"

This is the command in the terminal:

/usr/local/fsl/bin/fast "test.nii.gz"

They are exactly the same. But the shell script throw an error like this:

/Users/weiziyang/study/Final_Project/code/auto-seg.sh: line 2:  9502 Segmentation fault: 11  /usr/local/fsl/bin/fast "test.nii.gz"

I want it run successfuly!

(pasted from comment that turned out to be the right guess) Your fast binary is probably using some environment variable. A regular terminal is running as you, with your environment. A console may be running as root or some other user. Use env to print the environment in each shell and compare them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM