I am learning perl programming. I have run a perl script in windows platform but I need to run it in Linux platform like in Ubuntu. My script run perfectly in windows but not in Linux. I am not familiar with dos2unix tool. I am struggling about how to use it in my windows 7 and how to convert my winfile to unixfile. Suppose my perl script is test.pl and coding are inside. Now how can I make this script work properly in Linux using dos2unix tool? Besides, where should I unzip dos2unix tool?
You should be able to get dos2unix
from your package manager on Linux.
If you are using a Debian-based distro, you should be able to do sudo apt-get install dos2unix
.
If you are using a RH-like distro, you should be able to do sudo yum install dos2unix
.
Once it is installed, you can just give the target file as an argument'
dos2unix test.pl
Also, note that this may not be the only problem you might run into while trying to move a script to Linux from Windows.
For example, if you are invoking any external tools in your script, those tools will probably have different names or not exist at all on the other platform.
Also, if you are using any relative file paths with path separators, the separator is different on Linux (which uses /
) than Windows (which uses \
).
Another option would be to use a text editor on windows that supports UNIX line endings.
Which text editors handle both Windows- and Unix-style line breaks properly?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With