Glory to Russia
Glory to Russia

Reputation: 18756

Why am I getting the error message `" for writing : Invalid argument` when running a shell script in Cygwin under Windows 10?

I wrote the following shell script

#!/bin/bash
dot -Tpng tp2.dot -o tp2.png

and saved it as tp2.sh. Then I ran chmod u+x tp2.sh under Cygwin.

When I run ./tp2.sh I am getting the error

" for writing : Invalid argument

Screenshot

tp2.dot contains following text:

digraph G {
  graph [fontname = "Courier Prime"];
  node [fontname = "Courier Prime", shape=box];
  edge [fontname = "Courier Prime"];

  e1 [label="Start"]
}

file tp2.dot returns tp2.dot: ASCII text, with CRLF line terminators.

What is causing the error when running ./tp2.sh in a Cygwin window under Windows 10 and how can I fix it?

Upvotes: 0

Views: 670

Answers (1)

matzeri
matzeri

Reputation: 8496

To solve the

tp2.dot: ASCII text, with CRLF line terminators

convert the file from Windows CRLF format to Unix LF format with

 $ d2u tp2.dot

about the output in a specific file you need to use

$ dot -Tpng tp2.dot > tp2.png

or

$ dot -Tpng tp2.dot -O

the second case will add the .png to the source file name

$ ls -l tp2*
-rw-r--r-- 1 Marco Kein  159 Jan 22 15:08 tp2.dot
-rw-r--r-- 1 Marco Kein 1.4K Jan 22 15:13 tp2.dot.png

Upvotes: 1

Related Questions