sed command fails to edit when a sh file is executed using the custom command call.

Advertisement

Irfan S
Joined:
Posts:
4
Location:
Chennai, India

sed command fails to edit when a sh file is executed using the custom command call.

Hi Martin,
I am automating the process of editing a properties file with sed command.
I am generating a sh file in windows environment based on the input received from the user through GUI and then form the sed command with the old value and the new value like below. The below command will be available in the 'File1.sh' file
sed -i '/old/c\newvalue' /path/path/filename.properties

Then I will put this file in the remote machine with the put command and then execute the shell file with the 'call filename.sh' command.

But when I run the code (ie call /root/upload/config/File1.bat ), file editing is not successful. I get 'No such file or directory' error.
If I open the .sh file via winscp.exe editor make some changes then save it. Then if I execute the bat file manually, it is succeeded.
Not sure how to fix this issue.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,392
Location:
Prague, Czechia

Re: sed command fails to edit when a sh file is executed using the custom command call.

Again, what is the /root/upload/config/File1.bat? Why does (Windows) batch file have unix-style path? Where do you have that file? On Windows or on the server? What is in the file? What gives the "No such file or directory" error? Can you show us a screenshot?

Reply with quote

Irfan S
Joined:
Posts:
4
Location:
Chennai, India

sed command fails to edit when a sh file is executed using the custom command call.

Hi Martin,
I am automating the process of editing the .properties file using sed command.

"File1.bat" will be generated in windows that contains the sed command to edit the file
This File1.bat will be put to the linux machine
Then File1.bat will be executed using the custom command call

The error I was doing is when I put the file from windows to linux, I did not use any transfer options, hence I was getting "no such file or directory" error.
Once I change the -transfer option to ascii , the above issue was fixed.

However let me know if there is some better way of doing this.

Reply with quote

Advertisement

You can post new topics in this forum