Search code examples
perlkshclearcasecleartool

Use mkattr in perl script (Unix env)?


Clearcase command line mkattr needs to wrap variable $bug_num between single quote + quote + $varible + quote + single quote, like this:

cleartool mkattr -replace BUGNUM '"$bug_num"' clearcase_file

How to make a call of the command cleartool mkattr in a Perl script in Unix env? Env is Unix AIX and ksh


Solution

  • As mentioned in this recent answer:

    If you want to execute a system command and don't have to use any shell syntax like redirects, it's usually better and safer to use the list form of system:

    system(
        'cleartool',  'mkattr', '-replace', 'BUGNUM ',
        qq{"$bug_num"}, qq{clearcase_file}
    );
    # or, if you really want to pass both types of quotes:
    system(
        'cleartool',  'mkattr', '-replace', 'BUGNUM ',
        qq{'"$bug_num"'}, qq{clearcase_file}
    );
    

    Or:

    system(qq{cleartool mkattr -replace BUGNUM '"$bug_num"' clearcase_file});