* # as an incoming parameter to a Python script, you must use single quotation marks ' to pass in correctly. such as Python test.py ' * ' age
Python test.py * age is wrong.
Like what
The test.py script is as follows
Import Sys
Hdfs_report_historical_year = sys.argv[1]
# eg:2014-05,2014-12,etc.
Hdfs_report_historical_month = sys.argv[2]
# eg:all,region,citylevel,etc.
Pig_script_type = sys.argv[3]
Print Hdfs_report_historical_year
Print Hdfs_report_historical_month
Print Pig_script_type
It prints three incoming parameters. Invoke command
Python test.py * Age
Output:
[[email protected] new_pig]$ python test.py * age
2014
Age.pig
Appcategory.pig
You can see that the parameter * did not pass in correctly, but instead passed the file name in the current directory to sys.argv[2] and sys.argv[3]. To use the ' * ': Python test.py ' * ' age if you want to pass in correctly
We can see * No single quotes will pass through many parameters, test.py add parameters to print as follows
Import Sys
Hdfs_report_historical_year = sys.argv[1]
# eg:2014-05,2014-12,etc.
Hdfs_report_historical_month = sys.argv[2]
# eg:all,region,citylevel,etc.
Pig_script_type = sys.argv[3]
Print Hdfs_report_historical_year
Print Hdfs_report_historical_month
Print Sys.argv[4]
Print Sys.argv[5]
Print Sys.argv[6]
Print Sys.argv[7]
Print Sys.argv[8]
Run
[[email protected] new_pig]$ python test.py * age
2014
Age.pig
Appcategory.pig.backup
backup.py
Citylevel.pig
config.py
Config.pyc
As you can see, the current directory pathname is basically passed into the script.
So be careful.
Python script, incoming parameter * To use single quote ' * '