<< EOF does not work in cmd (windows os)

gmt begin plot png
gmt basemap -JM10i -R-10/62/11/53 -Ba4f2
gmt coast -S101/148/188 -EFR,EG,KW,DZ+g244/164/96 -A2000
gmt plot -Sa0.5c -W1 -Gred << EOF
02:21:05 48:51:25
003.0331 036.4635
31:14:09 30:02:40
47:36:00 29:10:00
EOF

Are you using bash or batch files? I suspect that in the later you can’t do << EOF (it doesn’t exist).

I hardly recomend you to use bash files.

Heartedly recommend bash

yes I use batch. thank you

As you said, you are using Windows OS, then EOF will not work there. Please try
echo.
ChatGPT always give this EOF thing (In case you are also trying to use it). I personally feel, ChatGPT isn’t reliable for GMT scripts. It give biased results.

You should copy the content of the EOF into a .txt file. For instance, if the file is named as VVV.txt, then the next line becomes

gmt plot -Sa0.5c -W1 -Gred VVV.txt

this is what I really do, but I need to plot just two or three points so I need to input them into the batch file.

I am not asking chatgpt, I use .txt files to plot data points but I ask if I can input two or three points in the batch file directly, I think echo is used for a single point?

You would have to do tedious things like this;

echo first point > tmpfile
echo second point >> tmpfile
echo third point >> tmpfile

And then plot tmpfile.

I was most interested in this problem: I want to teach my Lithosphere class how to use gmt tools; they all have Windows laptops, so I have been trying out the Windows version for 6.5.0. But there are problems:

  1. The GMT Command Prompt does not recognize <<EOF and so I don’t know what work around there is for this (e.g., to create ridge.txt in Ex. 33) – This is a major problem for me!
  2. The GMT Command Prompt picks up an invisible character used for Tab – fixed by removing tabs in the examples
  3. The GMT Command Prompt does not recognize the character # for comment lines – fixed by deleting those lines

But Problem 1 seems unsurmountable… any suggestions? Thank you so much!

Update: The workaround is to go the active directory, create ridge.txt and copy paste the two lat lon positions into it. Then the script finds the file and continues.

Hi,

Points 1 & 2 are known features. The Windows batch language simply does not support them (bash also does not recognize rem as a commentary)

(2) Is a copy past issue. Common to all shells

Solutions? There are several alternative command line tools for windows that provide the those facilities (MinGW, Cmder, ConEmu, GIT for windows, etc). But for me (a Windows user also) I just don’t use the << EOF thing.

Thanks for the feedback, much appreciated!

You didn’t say how one might create ridge.txt in the Windows Gmt Command Prompt, and so I suppose you are saying that one must use one of the alternative tools that you listed – to run gmt altogether? Which one(s) do you use? (I’m actually a Mac/Unix user but need to figure out Windows for my students.)

Well, that file has only two lines so you can do

echo -111.6 -43.0 > ridge.txt
echo -113.3 -47.5 >> ridge.txt

but normally, if I need a file, I create it outside of the script.

I use a mix of plain batch files, and rarely MinGW or the bash that comes with Wingit where the latter is simpler to install and inherits the Windows path automatically. But nowadays I use almost exclusively the GMT.jl Julia wrapper. The ex33 looks like this in GMT.jl

Thank you, very helpful! Onward to Julia then… Although, I was able, with my workaround, to run ex33 in the Windows gmt prompt. Interestingly the median profile of ex33 in Julia (and by me) does not precisely match that shown on the main docs page.

Well, you asked what I use. Happy to have you and your students as users but you don’t have to follow.

You mean that you got the same fig as in the Julia ex33 example?
Not sure if we always rebuild the examples in the docs with the latest versions of the grids (that got updated not long ago). That might explain the differences.