LinuxQuestions.org
Visit Jeremy's Blog.
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 11-17-2015, 07:54 AM   #1
siddhanta roy
LQ Newbie
 
Registered: Nov 2015
Posts: 6

Rep: Reputation: Disabled
Replace VAH path


Hi,
We are recently migrated from one server to another linux server.
With server, VAH name also got changed. We have lot shell scripts in the server referring to old VAH.
To make the scripts work we need to change the entries to new VAH , which is lot of work to be done.
I have given a thought for symbolic link. But the challenge is this scripts are not in one location. They are scattered into different directories. We also cronjob with full path.

Can someone help me with an easy way to achive this.

Regards
Sid
 
Old 11-17-2015, 08:31 AM   #2
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
What's VAH?

Even if the scripts are not all in the same location, it's not hard to devise a find command that checks if a file is a script and whether it contains the VAH (whatever that is). Then, depending on how the VAH is used, it can be corrected with the text processing tools in Linux.

But perhaps there is a solution with a symbolic link.

I just need to know what is VAH.
 
Old 11-17-2015, 11:05 AM   #3
siddhanta roy
LQ Newbie
 
Registered: Nov 2015
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thanks for reply.
VAH is File System. Lets say "/OLD_VAH/scritps" is used as a path in many scripts. We need to change "/OLD_VAH/scritps" to "/NEW_VAH/scritps".

What can be the easiest way?

Thanks
Sid
 
Old 11-17-2015, 11:11 AM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by siddhanta roy View Post
Thanks for reply.
VAH is File System. Lets say "/OLD_VAH/scritps" is used as a path in many scripts. We need to change "/OLD_VAH/scritps" to "/NEW_VAH/scritps".

What can be the easiest way?

Thanks
Sid
Perhaps you should post one of the original scripts, (sanitized of course)?

Thank you.

Last edited by Habitual; 11-17-2015 at 11:14 AM.
 
1 members found this post helpful.
Old 11-17-2015, 11:22 AM   #5
siddhanta roy
LQ Newbie
 
Registered: Nov 2015
Posts: 6

Original Poster
Rep: Reputation: Disabled
Hi,
This is nothing related to scripting and am sure original script won't help. But i can give u an example below.

#/bin/ksh
##### Load the required Variable ########
/OLD_VAH/scripts/old_variable.sh

###### Some Processing #############


########### Log file ##########

Some Processing >> /OLD_VAH/scripts/log_file.txt


As you can see, the above script call another script with its full path. There are may such type. I have 2 option
1) Search and change the path in all the script
2) Something like Symbolic Link at Global level.

Thanks
Sid
 
Old 11-17-2015, 11:42 AM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 25,642

Rep: Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651
Quote:
Originally Posted by siddhanta roy View Post
Hi,
This is nothing related to scripting and am sure original script won't help. But i can give u an example below.
You really need to read the LQ Rules and the "Question Guidelines" link in my posting signature. Don't use text speak, and if you're not going to provide examples, we're not going to be able to help you. We can't guess as to what you're talking about, and you need to ask a clear question[
Quote:
#/bin/ksh
##### Load the required Variable ########
/OLD_VAH/scripts/old_variable.sh
###### Some Processing #############
########### Log file ##########
Some Processing >> /OLD_VAH/scripts/log_file.txt

As you can see, the above script call another script with its full path. There are may such type. I have 2 option
1) Search and change the path in all the script
..which is what you need to do.
Quote:
2) Something like Symbolic Link at Global level.
...which is too vague for us to guess at. If you mean linking a directory, you CAN do that, but all you're doing is making things on the new system harder to maintain further down the road. Getting your scripts correct is the best thing to do.

Since you don't actually post a script, we can't tell you much.

Last edited by TB0ne; 11-17-2015 at 11:47 AM.
 
Old 11-17-2015, 12:26 PM   #7
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
http://www.cyberciti.biz/faq/unix-li...in-many-files/
https://duckduckgo.com/?q=find+and+replace+text+Linux

Last edited by Habitual; 11-17-2015 at 01:07 PM.
 
Old 11-17-2015, 01:08 PM   #8
siddhanta roy
LQ Newbie
 
Registered: Nov 2015
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Habitual View Post
If it's not related to scripting why does your answer say "change path in script"?
and your original post:



As you say, so shall it be.

Sucks to be you.
I'm done here.

Good Luck.
I believe i have given proper template example. If still it's not clear , you can mention that instead of giving any unproductive reply!
This is probably one line in 1000 line script and has nothing to do with any logic. Still if you think this is an scripting issue ,just by seing the word SCRIPT, then good you gave up!
 
Old 11-17-2015, 01:11 PM   #9
siddhanta roy
LQ Newbie
 
Registered: Nov 2015
Posts: 6

Original Poster
Rep: Reputation: Disabled
Smile


Thanks for the link! That will definitely help
 
Old 11-17-2015, 01:12 PM   #10
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 25,642

Rep: Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651
Quote:
Originally Posted by siddhanta roy View Post
I believe i have given proper template example. If still it's not clear , you can mention that instead of giving any unproductive reply!
I *DID* mention it, and TOLD YOU it wasn't clear. And if you had 'given proper template example', we wouldn't have asked.
Quote:
This is probably one line in 1000 line script and has nothing to do with any logic. Still if you think this is an scripting issue ,just by seing the word SCRIPT, then good you gave up!
And if you can't follow the posting guidelines, provide examples, or give us ANYTHING to work with, then there isn't much anyone, on any forum, can do for you.

Again, you can modify your scripts (which, AGAIN, you should do), or create a symbolic link (which SHOULDN'T be done). Pick one. If you're the administrator of a system, have root access to files, and have been asked to modify/change scripts and migrate data, you should have the knowledge you need to modify a script. If you have a lot of files to modify, look into the sed command, and pay particular attention to the "-i" switch.
Quote:
Originally Posted by siddhanta roy View Post
Thanks for the link! That will definitely help
And what prevented you from doing this search yourself?
 
Old 11-17-2015, 01:13 PM   #11
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by siddhanta roy View Post
I believe i have given proper template example. If still it's not clear , you can mention that instead of giving any unproductive reply!
This is probably one line in 1000 line script and has nothing to do with any logic. Still if you think this is an scripting issue ,just by seing the word SCRIPT, then good you gave up!
I have modified my previous reply.
I was unprofessional, and I apologize for that.
It's not personal.
 
1 members found this post helpful.
Old 11-17-2015, 01:23 PM   #12
siddhanta roy
LQ Newbie
 
Registered: Nov 2015
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Habitual View Post
I have modified my previous reply.
I was unprofessional, and I apologize for that.
It's not personal.
My apologies too for the counter attack :P
Thanks for you help!

I think the best way is to go with replacing the path in all the scripts.

Thanks
Sid
 
Old 11-17-2015, 01:46 PM   #13
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141
Two options:

1) Edit all of the scripts and change /OLD_VAH to $VAH_ROOT, then edit the system-wide shell profile to set VAH_ROOT to the VAH location on that system.

2) Symlink /OLD_VAH to /NEW_VAH

#2 is a hack that will get you up and running quickly. #1 is a more permanent and elegant solution that should be implemented once you have time.
 
1 members found this post helpful.
Old 11-17-2015, 06:14 PM   #14
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
Quote:
Originally Posted by suicidaleggroll View Post
Two options:

1) Edit all of the scripts and change /OLD_VAH to $VAH_ROOT, then edit the system-wide shell profile to set VAH_ROOT to the VAH location on that system.
Roughly:
Code:
cat > replace.sh <<THEENDOFIT
if [[ $(file $1) =~ "shell script" ]]
then sed -i 's/OLDPATH/NEWPATH/g' $1
fi
THEENDOFIT

find whateverpathisappropriate -type f -exec ./replace.sh {} \;
The problem is that it might not be correct to replace OLDPATH in some instances.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
replace path mmhs Linux - Newbie 7 10-25-2012 12:48 PM
[SOLVED] replace string with empty string of dir path ted_chou12 Linux - Newbie 3 04-02-2011 06:43 AM
replace a string in a file using a script with path containig / vimalraj Linux - Newbie 3 02-27-2010 12:15 AM
how to replace path nasridine Linux - Newbie 10 02-17-2010 06:05 PM
sed attempting to replace text with directory path emgey Programming 5 04-03-2008 07:05 PM

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

All times are GMT -5. The time now is 04:48 AM.

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