简体   繁体   中英

Bash Script File Descriptor echo

echo: write error: Bad file descriptor

Throughout my code (through several bash scripts) I encounter this error. It happens when I'm trying to write or append to a (one) file.

LOGRUN_SOM_MUT_ANA=/Volumes/.../logRUN_SOMATIC_MUT_ANA

I use the absolute path for this variable and I use the same file for each script that is called. The file has a bunch of lines just like this. I use the import '.' on each script to get it.

echo "debug level set for $DEBUG_LEVEL" >> ${LOGRUN_SOM_MUT_ANA}

Worth noting:

  • It typically happens AFTER the FIRST time I write to it.
  • I read about files 'closing' themselves and yielding this error
  • I am using the above line in one script, and then calling another script.

I'd be happy to clarify anything.

启动脚本

错误

第二个脚本,从第一个脚本调用

For others encountering the same stupid error under cygwin in a script that works under a real Linux: no idea why, but it can happen:

1) after a syntax error in the script

2) because cygwin bash wants you to replace ./myScript.sh with . ./myScript.sh . ./myScript.sh (where dot is the bash-style include directive, aka source )

I figured it out, the thumb drive I'm using is encrypted. It outputs to /tmp/ so it's a permission thing. That's the problem!

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