Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a functinon to check if an executable exists via popen #1539

Merged
merged 8 commits into from
Sep 8, 2019

Conversation

PaulWessel
Copy link
Member

We had several places where we did a special popen check, but I have consolidated those actions in a new gmt_check_executable () function that handles the common tasks. It is being called by psconvert.c and movie.c

We had several places where we did a special popen check, but I have consolidated those actions in a new gmt_check_executable () function that handles the common tasks.
@seisman
Copy link
Member

seisman commented Sep 8, 2019

The Windows build fails.

@PaulWessel
Copy link
Member Author

So it is because of directory with spaces in the name, Program Files. I guess

sprintf (cmd, "%s --version", Ctrl->G.file);
if (gmt_check_executable (GMT, cmd, NULL, cmd)) {	/* Found GhostScript */

needs to be

sprintf (cmd, "'%s' --version", Ctrl->G.file);

to ensure it is seen as a single name?

…aces

Windows paths such as Program Files are really smart.
@PaulWessel
Copy link
Member Author

@seisman I added single quotes around a program with spaces, but I don't see that reflected in the error message? Any suggestions?

@PaulWessel
Copy link
Member Author

I don't get it. It now says (I forced the first message to see what is passed to popen)

psconvert [ERROR]: gmt_check_executable: Pass to popen (in []):
['C:\Program Files\gs\gs9.26\bin\gswin64c.exe' --version > NUL]
The filename, directory name, or volume label syntax is incorrect.
psconvert [ERROR]: Cannot execute GhostScript ("C:\Program Files\gs\gs9.26\bin\gswin64c.exe").

I don't see the problem.

@seisman
Copy link
Member

seisman commented Sep 8, 2019

Always use double quotes?
image

@PaulWessel
Copy link
Member Author

I think I have tried every combination, but perhaps now. I will modify to do double quotes.

@PaulWessel
Copy link
Member Author

Seems like nothing works, single double nothing.

@PaulWessel
Copy link
Member Author

If you have Windows anywhere, can you paste in that command, with our without quotes etc and see if it should run?

@seisman
Copy link
Member

seisman commented Sep 8, 2019

image

It seems the command "C:\Program Files\gs\gs9.26\bin\gswin64c.exe" --version > NUL outputs stdout (gs version) to NUL. If that's true, how do you parse the version string? Maybe you should use 2> NUL?

@PaulWessel
Copy link
Member Author

Please try with a command that fails (e.g. gs7897987) vs one that works. So it writes the version to > NUL but error needs 2> NUL?

@seisman
Copy link
Member

seisman commented Sep 8, 2019

image

@PaulWessel
Copy link
Member Author

OK, pushed 2> NUL

@PaulWessel
Copy link
Member Author

Worked apparently, so OK to merge?

@PaulWessel PaulWessel merged commit f9ee859 into 6.0 Sep 8, 2019
@seisman seisman deleted the addexecutablechecker branch September 8, 2019 04:23
@joa-quim
Copy link
Member

joa-quim commented Sep 8, 2019

The function ghostbuster() already wrapped the G->file under double quotes. Is it now double wrapped?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants