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

Author Message
Irfan S
[View user's profile]

Joined: 2016-02-04
Posts: 4
Location: Chennai, India
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.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
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?
Irfan S
[View user's profile]

Joined: 2016-02-04
Posts: 4
Location: Chennai, India
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.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License