ovedpo15 has asked for the wisdom of the Perl Monks concerning the following question:
It's a bash script and I need to give it exec permissions, the same result as I get from chmod a+x script.sh. I could not figure a straightforward way to do this but I might miss it. For example, you can't pass it to the open sub. Also I came across with chmod but you need to pass a value (like 0777), instead of a+x and as I understand, it's not the same thing. Furthermore, I could just do `chmod a+x script.sh` right after creating the file, but I prefer a more of a perl-way. Is it possible to suggest a way?sub create_script { my ($script_path,$content) = @_; open(my $fh, '>', "$script_path") or die "Could not open script"; print $fh "set -x\n"; print $fh $content; close($fh); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Chmod a+x a file in Perl
by choroba (Cardinal) on Feb 15, 2022 at 19:10 UTC | |
|
Re: Chmod a+x a file in Perl
by atcroft (Abbot) on Feb 16, 2022 at 00:45 UTC | |
by atcroft (Abbot) on Feb 18, 2022 at 05:39 UTC | |
|
Re: Chmod a+x a file in Perl
by Anonymous Monk on Feb 16, 2022 at 17:53 UTC | |
by Anonymous Monk on Feb 16, 2022 at 18:08 UTC | |
by Anonymous Monk on Feb 17, 2022 at 16:21 UTC |