When a script is called, Perl is used to directly assign values to parameters input by the command line.

Source: Internet
Author: User
Tags perl script
I have a Perl script named A. pl, which contains a statement similar to the following to read the input value of the command line:
My $ device_name = <stdin>;
If I use the system or readpipe command in the B. pl script to bond the script a. pl, the command line prompts a value when running the preceding statement.
Sometimes, for example, in automated script testing, you want to allow script B. PL automatically enters this value, or, automatically in B. in the pl script. the variable $ device_name In the pl script is assigned a value.
In this way, ProgramYou can run all the tasks automatically without manual intervention.
You can use a statement similar to this in B. Pl to implement this function:
System ("echo Yes | Perl A. pl ");
Or
My @ dev_check_result = readpipe ("Echo". $ dev_file. "| Perl A. pl ");
In this way, when calling. when the command line prompts that you want to input a value to the variable $ device_name, the value of yes or $ dev_file is automatically assigned to. $ device_name variable in PL.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.