0
我有一个shell脚本,它执行一个Java程序,其中包含从另一个Java程序返回的参数。在shell脚本中执行java程序时使用双引号
java -cp $wekaPath $(java GetFilter $WandFDir) -i $(pwd)/temp/training"$i"_$arffName.arff -o $(pwd)/temp/training_"$i"_$arffName.arff
回荡时,它产生以下字符串:
java -cp /home/robobenny/Documents/WEKA/weka-3-7-4/weka.jar weka.filters.supervised.attribute.AttributeSelection -E "weka.attributeSelection.InfoGainAttributeEval" -S "weka.attributeSelection.Ranker -T -1.7976931348623157E308 -N 20" -c first -i /home/robobenny/Documents/WEKA/Pipeline/temp/training1_Test.arff -o /home/robobenny/Documents/WEKA/Pipeline/temp/training_1_Test.arff
这是伟大的,因为如果我的字符串复制到命令行,它运行Java程序没有发生任何事件。问题出现的时候,我不回应,并尝试从shell脚本执行它,我也得到来自终端的以下内容:
<!-- language: lang-none -->
Can't find class called: "weka.attributeSelection.InfoGainAttributeEval"
Filter options:
-S <"Name of search class [search options]">
Sets search method for subset evaluators.
eg. -S "weka.attributeSelection.BestFirst -S 8"
-E <"Name of attribute/subset evaluation class [evaluator options]">
Sets attribute/subset evaluator.
eg. -E "weka.attributeSelection.CfsSubsetEval -L"
Options specific to evaluator weka.attributeSelection.CfsSubsetEval:
-M
Treat missing values as a separate value.
-L
Don't include locally predictive attributes.
Options specific to search weka.attributeSelection.BestFirst:
-P <start set>
Specify a starting set of attributes.
Eg. 1,3,5-7.
-D <0 = backward | 1 = forward | 2 = bi-directional>
Direction of search. (default = 1).
-N <num>
Number of non-improving nodes to
consider before terminating search.
-S <num>
Size of lookup cache for evaluated subsets.
Expressed as a multiple of the number of
attributes in the data set. (default = 1)
General options:
-h
Get help on available options.
(use -b -h for help on batch mode.)
-i <file>
The name of the file containing input instances.
If not supplied then instances will be read from stdin.
-o <file>
The name of the file output instances will be written to.
If not supplied then instances will be written to stdout.
-c <class index>
The number of the attribute to use as the class.
"first" and "last" are also valid entries.
If not supplied then no class is assigned.
当我硬编码的$(java GetFilter $WandFDir)
在shell脚本输出:
java -cp $wekaPath weka.filters.supervised.attribute.AttributeSelection -E "weka.attributeSelection.InfoGainAttributeEval" -S "weka.attributeSelection.Ranker -T -1.7976931348623157E308 -N 20" -c first -i $(pwd)/temp/training"$i"_$arffName.arff -o $(pwd)/temp/training_"$i"_$arffName.arff
它也没有发生事故。有趣的是,当回声时,双引号消失。
java -cp /home/robobenny/Documents/WEKA/weka-3-7-4/weka.jar weka.filters.supervised.attribute.AttributeSelection -E weka.attributeSelection.InfoGainAttributeEval -S weka.attributeSelection.Ranker -T -1.7976931348623157E308 -N 20 -c first -i /home/robobenny/Documents/WEKA/Pipeline/temp/training2_Test.arff -o /home/robobenny/Documents/WEKA/Pipeline/temp/training_2_Test.arff
当我离开的双引号出$(java GetFilter $WandFDir)
我得到以下错误的输出:
<!-- language: lang-none -->
Illegal options: -T -1.7976931348623157E308 -N 20
Filter options:
-S <"Name of search class [search options]">
Sets search method for subset evaluators.
eg. -S "weka.attributeSelection.BestFirst -S 8"
-E <"Name of attribute/subset evaluation class [evaluator options]">
Sets attribute/subset evaluator.
eg. -E "weka.attributeSelection.CfsSubsetEval -L"
Options specific to evaluator weka.attributeSelection.InfoGainAttributeEval:
-M
treat missing values as a seperate value.
-B
just binarize numeric attributes instead
of properly discretizing them.
Options specific to search weka.attributeSelection.Ranker:
-P <start set>
Specify a starting set of attributes.
Eg. 1,3,5-7.
Any starting attributes specified are
ignored during the ranking.
-T <threshold>
Specify a theshold by which attributes
may be discarded from the ranking.
-N <num to select>
Specify number of attributes to select
General options:
-h
Get help on available options.
(use -b -h for help on batch mode.)
-i <file>
The name of the file containing input instances.
If not supplied then instances will be read from stdin.
-o <file>
The name of the file output instances will be written to.
If not supplied then instances will be written to stdout.
-c <class index>
The number of the attribute to use as the class.
"first" and "last" are also valid entries.
If not supplied then no class is assigned.
我环顾四周,似乎无法找到任何解决我的问题。
尝试这导致了'非法Options'错误。 – Robobenny 2013-04-10 19:46:24
echo $ var给你什么? – skirsch 2013-04-10 20:06:09
'weka.filters.supervised.attribute.AttributeSelection -E weka.attributeSelection.InfoGainAttributeEval -S -S weka.attributeSelection.Ranker -T -1.7976931348623157E308 -N-20 -c first' -so没有双引号版本。 – Robobenny 2013-04-10 20:09:50