Reputation: 1570
I have the following bash code which I want to run within a perl script. As a bash script the code runs without any error. But in the perl script it gives the error: Bad name after bash' at ./061_rewrite_aws.pl line 48.
system(' 'bash' '-c' <<'END_SHELL_CODE';
AWS_Base="/run/user/1000/gvfs/smb-share:server=192.168.0.205,share=zmd-backup"
pushd /home/zmd/AWS/AWS_DataDirs
cp -R $AWS_Base/* ./
popd
'END_SHELL_CODE' ');
Assistance will be appreciated
Upvotes: 0
Views: 60
Reputation: 1350
I think there's just some quoting errors with that line of perl.
system
takes a list of strings as arguments, so I changed that quoting to be a list of strings.
bash
to be the name of some variable.;
after END_SHELL_CODE on the first line, and having END_SHELL_CODE
in single quotes at the end didn't work with perl's formatting, so I removed that.Something like this worked for me:
system('bash', '-c', <<'END_SHELL_CODE'
AWS_Base="/run/user/1000/gvfs/smb-share:server=192.168.0.205,share=zmd-backup"
pushd /home/zmd/AWS/AWS_DataDirs
cp -R $AWS_Base/* ./
popd
END_SHELL_CODE
);
Upvotes: 2