Running GMT example as powershell cmdlet fault

i tried to run ex#44 with a little improvements as cmdlet (powershell ver 5.1 on Windows 7. GMT 6.3.0) and got the error mrssages

inset [ERROR]: Unrecognized option -<
inset [ERROR]: In end mode and information file does not exist: C:/Users/****/.gmt/sessions/gmt_session.1812/gmt.inset.0

The result is not as expected
I checked that the command did not actually create the required file gmt.inset.0. Apparently something is missing in this GMT using (409 Байт) (634.9 КБ)
Please, can you help with advice in this case?


Hard to tell. The message is the kind of error one gets when you inadvertently give what looks like a filename to the module when no such is expected, e.g.

gmt basemap -RFR -Gred -B Lstuff -pdf t
basemap [ERROR]: Unrecognized option -<

Maybe you edited and introduced something on the inset command line?

In lack of other more informed information, just forget powershell and use cmd. It has always screwed for me too.

I see that in your scipt you use:

gmt coast -R15W/35E/30N/48N $p -Da -Gbrown -B0 -EES+gbisque 

I am not sure if $p works on cmd or powershell.

Fairly sure it doesn’t; it would be too easy.

My suggestion is to install WSL if you can, and use bash. Don’t pain yourself with cmd and batch.

(Waiting for joaquim to recommend julia :blush:)

If you use the “long hyphen” that fancy editors might do the -JM may not be what you think it is and it is seen as a file name.

Yes: copy/paste from cookbook/docs often comes with a gotcha.

This replacement works fine. You can verify this by viewing the contents of the ps file. Or I can remove the variable. The rezult does not changes
cmd or Powershell is not my pain.

The mystery is that i don’t use “long hyphen” or something unexpected
i ran a couple of other random examples and got the same messages
The script generates something extra that leads to errors
But the other error independently presents.
a temporary file really is not created and therefore the subsequent command does not receive the parameters it needs
I changed zip with more corrected ps1 file, but the behavior of the script remains the same

How rewrite script to use two subplots?
and another unresolved problem is. Sign ‘?’ does not work like in cmd. So I had to replace it with a constant

if i removed all insets no error messages appeared

The fact is that the cmd functionality has ceased to satisfy. Powershell is the part of Windows and in some cases i cant install something extra to automate my tasks
I like powershell indeed

Isn’t that yet obvious :joy:?

1 Like

The problem is that the gmt inset command for whatever reason sees an input file and thus exits, therefore not completing the setup for the inset and it is all downhill from there. Do you have a way to tell the powershell to echo back the command that it is trying to execute? It is clearly nothing wrong with but there may be some shell incompatibilities between powershell and standard unix shells.

can’t think of a way to repeat the powershell command
can’t get into the “inset begin” command
but a can find difference in two ps files (bat/ps1).
The Powershell version does not generate the next expected line “gmt inset begin”
Command “gmt inset begin” does not generate temporary file because it met with an unexpected argument
If i remove "-F+gwhite+p1p+c0.1c+s " One error message does not appear
Maybe the reason is in passing arguments?
I tried every way I know how to run commands with the same result.
It’s sad but powershell and “inset begin” don’t match for today

So i tried Ex44 from GMT 5.4.5 (only two first string)
gmt pscoast -R110E/170E/44S/9S -JM6i -P -Baf -BWSne -Wfaint -N2/1p -EAU+gbisque -Gbrown -Sazure1 -Da -Xc -K --FORMAT_GEO_MAP=dddF |Out-file $ps -Encoding ASCII
gmt psbasemap -R -J -O -DjTR+w1.5i+o0.15i/0.1i+stmp -F+gwhite+p1p+c0.1c+s |out-file $ps -Append -Encoding ASCII
Two error messages (inset [ERROR]: Unrecognized option -<) printed, but the map is plotted

PS I’ve tested CMD version of Ex52. Maybe it will be useful to you (824 Байта)

What is with the -Encoding ASCII? Is that added by the powershell or you? If that is part of the command then that explains the-< error message.

" |Out-file $ps -Encoding ASCII " is an analogue of cmd “>” . Means the simple redirect of stdout to file. To specify powershell write ASCII bytes (not UTF-16 with BOF by default)
There is the ordinary comment in ps file without extra arguments (is the copy of input string)
%@GMT: gmt pscoast -R110E/170E/44S/9S -JM6i -P bla-bla-bla
its looks like a miracle error message. But the “?” characters talking about incorrect output
So this message in inset command exist not only for 6x version

I see. Well, looks terrible convoluted to me but you be the judge of that.
It then seems likely that ? is seen as a special character. Perhaps you need to put quotes around the argument with the question mark so it is not interpreted by the powershell to mean something else.

I had to remove the use of the sign in the script altogether, this is not a basic possibility (syntax sugar).
Although I tried to leave it in different versions.
But in this case, something does not work at the charset layout, degree symbol expected at this place
uncertainty using of “inset" more important

“every avenue is a dead end”

My previous experience with PS was that the the postscript file itself was corrupted for non-comprehensible reason. That’s when I gave up.

Currupted file is not a problem. The reason described above.
The real difficulty lies in the obscure parameter passing mechanism.
The simple strings from ex#52
gmt grdgradient earth_relief_20m_p.grd -Nt0.5 -A45 -Gintens.grd
gmt grdmix earth_day_20m_p.tif earth_night_20m_p.tif -Ww.grd -Iintens.grd -Gview.tif
causes a bunch of errors

grdgradient [ERROR]: Option -N: Normalization amplitude must be > 0
grdmix [ERROR]: Option W: Bad value or a file that was not found: w
grdmix [ERROR]: Cannot find file .grd
grdmix [ERROR]: Option I: Bad value or a file that was not found: intens
grdmix [ERROR]: A maximum of three rasters may be provided
grdmix [ERROR]: A maximum of three rasters may be provided
grdmix [ERROR]: For three input images you must select -C

Execution just doesn’t get to the creation of the ps file

I am sure powershell may be very good for some things but it seems to be useless as a Unix shell compliant replacement.