Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
281 views
in Technique[技术] by (71.8m points)

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?

question from:https://stackoverflow.com/questions/65846492/why-am-i-getting-the-error-message-for-writing-invalid-argument-when-runni

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...