LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-02-2019, 12:55 AM   #1
SunitaManju
LQ Newbie
 
Registered: Mar 2019
Posts: 3

Rep: Reputation: Disabled
Angry SED not working on remote server


Hi All,

I have a file 'test.sh' on a remote server that contains sed command:

NEWSCRIPTDIR=`echo $SCRIPTDIR | sed 's:'$IAP_BATCH_PATH':'$IAP_DATA_PATH':'`

I am executing this script from another server by doing ssh:

ssh @server /path/test.sh

However, the sed command in test.sh script is not replacing the string and throwing the error "sed: -e expression #1, char 0: no previous regular expression line 17: /COMMON/envParams.sh: No such file or directory"

When i execute the test.sh script on the remote server itself,the sed command is working fine.

kindly assist.

Last edited by SunitaManju; 04-02-2019 at 01:14 AM.
 
Old 04-02-2019, 01:02 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
I have to say: no, sed is working. This line cannot produce that error message.
 
Old 04-02-2019, 04:02 AM   #3
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
I would echo the values of SCRIPTDIR, IAP_BATCH_PATH and IAP_DATA_PATH to gain clarity. They may contain characters that make sed stumble.

Also a suggestion: Put the sed expression in double quotes to avoid mistakes from overly complicated string concatenations, and from white space or other special characters in the shell variables.

Last edited by berndbausch; 04-02-2019 at 04:05 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
scp : -l option (bandwidth limiting) doesn't work when scp-ing from a remote server to another remote server stoorky Linux - Server 10 03-05-2018 03:28 AM
sudo connect to a remote server and execute scripts in remote server masubram Linux - Newbie 6 07-31-2016 09:35 AM
[sed] "Advanced" sed question(s) G00fy Programming 2 03-20-2006 12:34 AM
sed and escaping & in something like: echo $y | sed 's/&/_/g' prx Programming 7 02-03-2005 11:00 PM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 06:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration