To run a bash script (Example: bash-script.sh) from inside a perl script, you could use the following syntax:
Note: Here, once the bash script completes execution it will continue with the execution of the perl script.
Perl Script: perl-script.pl
Bash Script: bash-script.sh
Below is a perl script “perl-script.pl” which calls an external bash script “bash-script.sh”.
print "Running parent perl script. \n";
print "Starting to call external bash script\n";
# Sample Argument to be passed to the bash script
my $my_arg = "ARG1";
# With arguments - pass them inside quotes seperated by commas
print "Back to parent perl script\n";
Below is the sample “bash-script.sh” which prints the variable.
echo "---Start of Bash script---"
echo "Argument from Perl script is" $a
To test, execute the perl script:
After a fresh install of Ubuntu, my terminal was being flooded with “print_req_error: I/O error, dev fd0, sector 0” error.
This is because, your kernel thinks you have a floppy disk fd0, but cant find one. To fix this issue, you can run the following in your terminal:
sudo rmmod floppy
echo "blacklist floppy" | sudo tee /etc/modprobe.d/blacklist-floppy.conf
sudo dpkg-reconfigure initramfs-tools
EDIT: Thanks @Joanmi for your comment (For the noticing the issue with sudo command.)
Misc: If you are deploying a new virtual machine, you can avoid this issue by deleting the Floppy Disk drive.
While using “dd”, by default it does not show the progress nor status of the transfer. However, you could use the flag “status=progress” to show the status/progress of the transfer. Here is a screenshot:
This flag is available in the newer version of dd. Here are the CLI outputs for the text ninjas:
$ sudo dd if=archlinux-2019.06.01-x86_64.iso bs=4M of=/dev/sdd status=progress oflag=sync
641728512 bytes (642 MB, 612 MiB) copied, 16 s, 39.1 MB/s
153+1 records in
153+1 records out
643825664 bytes (644 MB, 614 MiB) copied, 16.4601 s, 39.1 MB/s
PS: Use dd (data duplicator) with caution. ‘dd‘ is also known as disk destroyer in an alternate universe.