通过命令行将文件名作为字符串传递到 Maple
Pass file name as a string through command line into Maple
我正在尝试使用命令行界面在外部程序中使用 Maple 函数。函数的数据将通过文件传递。为了演示这个问题,我创建了两个文件:/home/user_name/test.mpl 和 /home/user_name/test_data.txt.
test.mpl("cat"演示Maple函数的使用):
#filename := "/home/user_name/test_data.txt":
print(filename):
i := parse(readline(filename)):
poly := parse(readline(filename)):
s := parse(readline(filename)):
print(cat(convert(poly+i,string), " ", s)):
测试_data.txt :
1
x^2 * y + 1
"A string."
根据 manual,我可以使用类似的东西(但是这个例子不包括两个文件的用法,一个作为代码,另一个作为参数):
/usr/local/maple/bin/maple -c 'datafile:="/tmp/12345.data";' -c N:=1;
当我尝试时
/path/to/maple -c 'filename:="/home/user_name/test_data.txt":' -q /home/user_name/test.mpl
我收到以下错误:
Error, incorrect syntax in parse: `/` unexpected (near 11th character of parsed string)
如果我删除文件名字符串中的第一个 /
,我会得到以下输出(在与 readline
相关的错误之前):
/ home \
|-------------------| . txt
\user_name test_data/
它清楚地表明文件路径没有被解析为字符串(但可能是某种表达式)。可能我应该为 Maple 或 shell 使用一些转义序列,但我的 none 尝试成功了。
如果我在 test.mpl 中获取文件名(取消注释那里的第一行并删除 -c
参数),它虽然有效,但这不是我需要的。
如何通过命令行将文件名作为字符串传递(可能不使用 -c
)?
我在 Linux 上使用命令行 Maple 对我有用,比如
/path/to/maple -c 'filename:=\"/home/user_name/test_data.txt\":' -q /home/user_name/test.mpl
我正在尝试使用命令行界面在外部程序中使用 Maple 函数。函数的数据将通过文件传递。为了演示这个问题,我创建了两个文件:/home/user_name/test.mpl 和 /home/user_name/test_data.txt.
test.mpl("cat"演示Maple函数的使用):
#filename := "/home/user_name/test_data.txt":
print(filename):
i := parse(readline(filename)):
poly := parse(readline(filename)):
s := parse(readline(filename)):
print(cat(convert(poly+i,string), " ", s)):
测试_data.txt :
1
x^2 * y + 1
"A string."
根据 manual,我可以使用类似的东西(但是这个例子不包括两个文件的用法,一个作为代码,另一个作为参数):
/usr/local/maple/bin/maple -c 'datafile:="/tmp/12345.data";' -c N:=1;
当我尝试时
/path/to/maple -c 'filename:="/home/user_name/test_data.txt":' -q /home/user_name/test.mpl
我收到以下错误:
Error, incorrect syntax in parse: `/` unexpected (near 11th character of parsed string)
如果我删除文件名字符串中的第一个 /
,我会得到以下输出(在与 readline
相关的错误之前):
/ home \
|-------------------| . txt
\user_name test_data/
它清楚地表明文件路径没有被解析为字符串(但可能是某种表达式)。可能我应该为 Maple 或 shell 使用一些转义序列,但我的 none 尝试成功了。
如果我在 test.mpl 中获取文件名(取消注释那里的第一行并删除 -c
参数),它虽然有效,但这不是我需要的。
如何通过命令行将文件名作为字符串传递(可能不使用 -c
)?
我在 Linux 上使用命令行 Maple 对我有用,比如
/path/to/maple -c 'filename:=\"/home/user_name/test_data.txt\":' -q /home/user_name/test.mpl