command-line - 通过命令行将文件名作为字符串传递到 Maple 中

标签 command-line command-line-arguments filenames 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)):

test_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 使用一些转义序列,但我的尝试都没有成功。

如果我在 test.mpl 中获取文件名(取消注释第一行并删除 -c 参数),它虽然可以工作,但这不是我需要的。

如何通过命令行将文件名作为字符串传递(可能不使用 -c)?

最佳答案

它对我在 Linux 上使用命令行 Maple 有效,例如,

/path/to/maple -c 'filename:=\"/home/user_name/test_data.txt\":' -q /home/user_name/test.mpl

关于command-line - 通过命令行将文件名作为字符串传递到 Maple 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42764443/

相关文章:

windows - 如何按照用户输入指定的次数运行命令?

php - 如何从命令行判断哪些 Screen session 仍在运行 PHP 进程?

java - 破折号和参数是否有任何标准的命令行约定?

Golang Flag 被解释为第一个 os.Args 参数

java - C 中的命令行参数导致段错误?

file - 更改文件名

scala - 全局禁用 sbt supershell

command-line - ImageMagick - 合并多个图像并居中

html - 如何强制下载的 gzip 数据 URI 的文件扩展名?

python - Sublime Text : How to get the file name of the current view