0

I am trying to use a simple bash script that uses a script in /opt

#!/bin/bash
pvpython=/opt/paraviewopenfoam54/bin/pvbatch
script_path=save_contours.py
$pvpython $script_path

The file pvbatch does exist, however when I try to run the script I get this strange error message which feels like it is missing some characters:

: No such file or directoryaviewopenfoam54/bin/pvbatch

The Ubuntu I am using is Ubuntu 18.04.1 LTS inside a Windows subsystem for Linux. What could cause this error message?

When I run ls -al pvbatch in /opt/paraviewopenfoam54/bin I get

-rwxr-xr-x 1 root root 84200 May 29  2018 pvbatch

cat pvbatch returns an error message

cat: write error: Input/output error
Axel
  • 1,415
  • 1
  • 16
  • 40
  • Absolutely nothing about your batch file tag could cause it. It's not a batch file. –  Feb 10 '20 at 08:12
  • Bash I meant bash... I am sorry. – Axel Feb 10 '20 at 08:27
  • The "No such file or directory" part is definitely due to DOS carriage returns in your script file; this is a common FAQ [Are shell scripts sensitive to encoding and line endings?](https://stackoverflow.com/questions/39527571/are-shell-scripts-sensitive-to-encoding-and-line-endings) – tripleee Mar 24 '21 at 06:01

2 Answers2

1

So cat cant read the file which is strange!

My first thought is that there is an issue with the file itself. where was the file created? I see that it is under /opt/paraviewopenfoam54/bin which is a linux managed folder, did you create and edit the file using vim in WSL or did you create it in windows somehow with VS Code or the like?

Let me just check that you are not creating and editing files in windows directly in the /opt folder inside the %LOCALAPPDATA% folders. If the file was created in this method you risk corrupting the WSL installation. Dont Edit WSL files

Damo
  • 5,698
  • 3
  • 37
  • 55
  • The file was actually created when installing OpenFOAM inside the Linux subsystem. I never touched it manually, neither using vim nor from Windows. – Axel Feb 10 '20 at 13:22
  • I'm running out of ideas, can you vim the file? i would look into the error `cat: write error: Input/output error` as if you cant pipe the file to cat chances are you cant run it either. – Damo Feb 10 '20 at 13:52
  • I just opened `pvbatch` in vim and it basically only consists of repeating `^@`. What does that mean and how did this happen? – Axel Feb 10 '20 at 14:15
  • sounds like a corrupt file, i cant say how it got like this, as my answer states one possible way is if it gets edited from windows, but since you didnt do this i dont know. Maybe try reinstalling OpenFOAM whatever this is, can you get in touch with the devs responsible for that app/service – Damo Feb 10 '20 at 17:14
-1

When using WSL I commonly find issues and especially this Input/output error issue whenever I create a file directly from windows into the Linux filesystem. There are essentially three main ways to fix this specific issue: (these are not steps but rather separate solutions)

-Restart your Ubuntu terminal

-Restart your entire computer

-Delete the file directly from Windows, touch the file, then overwrite the file with the old one

For a more scalable solution, I recommend leaving the file within the windows system and only working within the Linux system within Linux.

guninvalid
  • 411
  • 2
  • 5
  • 16