mersenneforum.org  

Go Back   mersenneforum.org > Great Internet Mersenne Prime Search > Software

Reply
 
Thread Tools
Old 2012-05-13, 14:05   #1
James Heinrich
 
James Heinrich's Avatar
 
"James Heinrich"
May 2004
ex-Northern Ontario

62508 Posts
Default Passing commands to PARI on Windows

edit: 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.


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.

On *nix, it does as expected:
Code:
# echo "Mod(2,2383)^397" | /usr/local/bin/gp -q
Mod(1, 2383)
But on Windows it just says back to me:
Quote:
"Mod(2,2383)^397"
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)
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
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
                                      ^---
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
                                      ^---
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)
So there you have it. On the rare chance that someone runs into this problem, I hope this saves you some headache.
James Heinrich is online now   Reply With Quote
Old 2012-05-13, 15:30   #2
Xitami
 
Apr 2010

E16 Posts
Default

echo eval(" 2+2^2 ") | gp -q
Xitami is offline   Reply With Quote
Old 2012-05-13, 19:19   #3
James Heinrich
 
James Heinrich's Avatar
 
"James Heinrich"
May 2004
ex-Northern Ontario

23·34·5 Posts
Default

Oh, that works

Thanks!
James Heinrich is online now   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
PARI's commands 3.14159 PARI/GP 2631 2018-09-26 15:26
Passing on manual work CuriousKit Information & Answers 13 2015-02-27 01:11
Ubiquity commands Mini-Geek Aliquot Sequences 1 2009-09-22 19:33
Are these commands correct? jasong Linux 2 2007-10-18 23:40
Passing input numbers to ECMNet as formulae? bearnol GMP-ECM 2 2006-02-23 20:23

All times are UTC. The time now is 23:03.

Sun Jan 17 23:03:37 UTC 2021 up 45 days, 19:14, 0 users, load averages: 1.44, 1.66, 1.70

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

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.