I want to edit a file; it's the chromedriver.exe. The problem is that when I write this command:
perl -pi -e 's/cdc_/dog_/g' /path/to/chromedriver
It replies: "No such file or directory."
Where must I place my file, or how can I edit it?
I want to edit a file; it's the chromedriver.exe. The problem is that when I write this command:
perl -pi -e 's/cdc_/dog_/g' /path/to/chromedriver
It replies: "No such file or directory."
Where must I place my file, or how can I edit it?
You mentioned that you want to edit chromedriver.exe
, but your command was:
perl -pi -e "s/cdc_/dog_/g" /path/to/chromedriver
Instead, use:
perl -pi -e "s/cdc_/dog_/g" /path/to/chromedriver.exe
# see the difference starting here --------------^
... to match the actual filename. Be sure to back up the original file if it's not easily recoverable!
As a side note, I found this similar question from Jun 26, 2021 that pointed to a comment:
Ok, I reinstalled Chrome WebDriver, did NOT run the Perl script, instead ran hex editor and everything works now. Devs, don't make the same mistake as me of running that script; I have no idea what's wrong with it and have no time to check, but it didn't work. Find+Replace in Hex Editor instead!
As a second side note, Kyle made a comment that points out an important point:
Keep the $ mark and don't change the length of the key, and you'll be fine
I noticed that your perl script doesn't require a leading $
, so without being sure what you're trying to replace, I might suggest:
perl -pi -e "s/\$cdc_/\$dog_/g" /path/to/chromedriver.exe
ikegami pointed out that editing a binary file may corrupt it by adding carriage returns to each line. They suggest adding binmode
to the input and output streams:
perl -pi -e "BEGIN { binmode STDIN; binmode STDOUT } s/\$cdc_/\$dog_/g" /path/to/chromedriver.exe