Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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".
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)?
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.
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.
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!
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
Thanks for the link! That will definitely help
And what prevented you from doing this search yourself?
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) 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) 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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.