【问题标题】:Pass file name as a string through command line into Maple通过命令行将文件名作为字符串传递到 Maple
【发布时间】:2017-03-13 13:06:56
【问题描述】:

我正在尝试使用命令行界面在外部程序中使用 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)?

【问题讨论】:

    标签: command-line command-line-arguments filenames maple


    【解决方案1】:

    它适用于我在 Linux 上使用命令行 Maple,例如,

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-08
      • 1970-01-01
      • 1970-01-01
      • 2011-03-14
      • 1970-01-01
      • 2021-02-09
      • 2014-02-03
      相关资源
      最近更新 更多