mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Software (https://www.mersenneforum.org/forumdisplay.php?f=10)
-   -   Passing commands to PARI on Windows (https://www.mersenneforum.org/showthread.php?t=16809)

James Heinrich 2012-05-13 14:05

Passing commands to PARI on Windows
 
[i]edit:[/i] This started off as a help-request thread, but I have solved my own problem while typing it. It may yet contain useful information, so I'll post anyways. :smile:


I have a code snippet (which I got from someone here, but I seem unable to find the original thread) for authenticating whether a factor actually divides a Mersenne exponent. And it works very nicely... but not on Windows. :sad:

On *nix, it does as expected:[code]# echo "Mod(2,2383)^397" | /usr/local/bin/gp -q
Mod(1, 2383)[/code]But on Windows it just says back to me:[quote][COLOR="teal"][B][FONT="Courier New"]"Mod(2,2383)^397"[/FONT][/B][/COLOR][/quote]with quotes and everything. But it does work fine within PARI itself, it's just a command-passing issue.[code]C:\Users\User>"C:\Program Files (x86)\PARI\gp.exe" -q
(10:03) gp > Mod(2,2383)^397
Mod(1, 2383)[/code]

I had run into this problem before when trying to factor reported factors, and made these notes:[code]// fail: echo 'factor(1234)' | "C:\Program Files (x86)\PARI\gp.exe" -q :: *** unused characters: 'factor(1234)'
// fail: echo "factor(1234)" | "C:\Program Files (x86)\PARI\gp.exe" -q :: %1 = "factor(1234)"
// work: echo factor(1234) | "C:\Program Files (x86)\PARI\gp.exe" -q
[/code]So Windows doesn't like quoted strings in this context, but does work just passing the raw command.

Except when you get to the current problem, because the caret is a special character:[code]C:\>echo Mod(2,2383)^397 | "C:\Program Files (x86)\PARI\gp.exe" -q
*** unused characters: Mod(2,2383)397
^---[/code]So you might think escaping it would help, but no:[code]C:\>echo Mod(2,2383)^^397 | "C:\Program Files (x86)\PARI\gp.exe" -q
*** unused characters: Mod(2,2383)397
^---[/code]Unless, that is, you double-escape it:[code]C:\Users\User>echo Mod(2,2383)^^^^397 | "C:\Program Files (x86)\PARI\gp.exe" -q
Mod(1, 2383)[/code]

So there you have it. On the rare chance that someone runs into this problem, I hope this saves you some headache.

Xitami 2012-05-13 15:30

echo eval(" 2+2^2 ") | gp -q

James Heinrich 2012-05-13 19:19

Oh, that works :cool:

Thanks!


All times are UTC. The time now is 12:54.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.