Is it possible to change paths inside a bash script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Is it possible to change paths inside a bash script?
# 15  
Old 08-08-2016
No, no, there is a file in folder which contain name same as the name of the zip file. So when unzip, it change name of the that file, not zip archive.
# 16  
Old 08-08-2016
We obviously have a language barrier here, but I believe the code I suggested in post #12 meets your stated requirements.

However, I am concerned that:
  1. all of your zip files are being unzipped into a single directory,
  2. a single configuration file is being edited every time you run this script, and
  3. the command to run after updating an existing source file or installing a new source file never changes.
All three of these points seem strange to me, but without knowing:
  1. what files are in your zip archives,
  2. why the file configfile.txt needs to be edited every time you install a new file with a .d filename extension, and
  3. what the command service something restart does
it is very hard to guess at what you are trying to do or to determine whether or not any of the code I suggested will be of any use to you.
# 17  
Old 08-09-2016
Quote:
  1. what files are in your zip archives,
  2. why the file configfile.txt needs to be edited every time you install a new file with a .d filename extension, and
  3. what the command service something restart does
1. It is some sertificates
2. Because it will allways go to another PC, not to the same
3. Its just a restart of some service (apache, mysql, etc).

So for a brief explanation of task. You have one zip file that should be unziped to some folder. On of unziped file contains a extension that need to be renamed. Then config file must be changed, and restart some service. Thats all that is need to be done.
# 18  
Old 08-09-2016
Quote:
Originally Posted by tomislav91
1. It is some sertificates
2. Because it will allways go to another PC, not to the same
3. Its just a restart of some service (apache, mysql, etc).

So for a brief explanation of task. You have one zip file that should be unziped to some folder. On of unziped file contains a extension that need to be renamed. Then config file must be changed, and restart some service. Thats all that is need to be done.
You don't seem to realize what your script is doing:
  1. OK. Having certificates in a file ending with the filename extension .c (which by convention is used to indicate that it is a C programming language source code file) is confusing, but now I understand why you might want to change the filename extension from .c to .d.
  2. No. Exactly the same change is made to the exact same file (/root/Documents/test/configfile.txt) every time your script is run. How does that identify a different server???
  3. Not some service. The same service every time you run your script. The command service something restart would seem to always restart the something service (not apache, not mysql; nothing by the single service named something).
  4. Not to some folder. Always to the same folder (/root/Documents/test) every time your script is run.
The only things that change every time your script is run are:
  1. the name of the zip archive and
  2. the name of the file that is renamed in the directory /root/Documents/test.
Everything else in your script is a constant.
# 19  
Old 08-10-2016
but yeah, thats idea. Extensions are just a examples. I dont need to determine other machines. When I execute script it needs to do what to, unzip, copy, etc. So in every other machines it will be doing the same, thats the point.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Make change to variable value inside of awk script

Hello, I have text data that looks like this, Mrv16a3102061815532D 6 6 0 0 0 0 999 V2000 -0.4018 1.9634 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 -1.1163 1.5509 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 -1.1163 0.7259 ... (9 Replies)
Discussion started by: LMHmedchem
9 Replies

2. Shell Programming and Scripting

Aliases NOT working inside bash shell script

i have defined a function ln_s() for customizing the ln command in script1.sh. more script1.sh echo "Starting Execution" ./script2.sh echo "End of Execution" ln_s(){ ] && return ln -s "$1" "$2" } My script1.sh executes another script2.sh which has the following entry more script2.sh... (12 Replies)
Discussion started by: mohtashims
12 Replies

3. Shell Programming and Scripting

Run bash command inside zsh script

Hi, I would like to run following code in bash inside a zsh script. (In this case is output unfortunately very different if you run it in zsh). I tried to put "bash" in front of the code but I obtained following error message "bash: do: No such file or directory " eve though I merged the whole... (7 Replies)
Discussion started by: kamcamonty
7 Replies

4. Shell Programming and Scripting

Expect not working inside my Bash script

I am trying to execute expect command inside by small bash script to login into servers using key authentication method. My script is as follows: #!/bin/bash HOST=$1 /usr/bin/expect -c " spawn ssh -i /root/.ssh/id_rsa root@$HOST expect -exact "Enter... (3 Replies)
Discussion started by: John Wilson
3 Replies

5. Shell Programming and Scripting

Why commands inside bash script lost effectiveness?

Hi, I have a bash script to run many system commands on CentOS machine, but I am puzzled by some commands had no effect on parent environment. For example, I want to refresh the desktop xdg menu when some processes added or deleted items from desktop xdg menu. If I run "killall gnome-panel"... (4 Replies)
Discussion started by: hce
4 Replies

6. Shell Programming and Scripting

How to change the color inside email using shell script?

hi, i want to send an email from unix using mailx command. mailx -s "subject" "email@abc.com" < email.txt Email.txt contains some file names that are transferred successfully and some that failed. so the files that got failed to tranfer, should be displayed in red color in the mail. is it... (1 Reply)
Discussion started by: Little
1 Replies

7. UNIX Desktop Questions & Answers

Change name of files to their paths -- find loop

Dear All, I have many sub-folders but each of them have a file with same name but different data. I want to either move or copy them into a new folder but they need to have the path of where they are coming as part of their name... I have managed to find the files but dont know how to change... (2 Replies)
Discussion started by: A-V
2 Replies

8. Shell Programming and Scripting

Tracking change inside the script

we have more then 10 jobs scheduled in cronjob.. but we can see some of the script has been changed without any notification.. can we write any script which captures any changes inside the scripts with time of change and user name like .. or any other option apart from this ?? Plz help .. (4 Replies)
Discussion started by: netdbaind
4 Replies

9. UNIX for Dummies Questions & Answers

using awk inside bash script?

Hello, I'm trying to write a bash script that will query the current system time (OS X 10.6.6) and then convert the output from HH:MM:SS into time in seconds. The output of the system time command (systemsetup -gettime) is returned as: Time: HH:MM:SS so I wanted to use awk -F: to grab... (5 Replies)
Discussion started by: xaiu
5 Replies

10. Shell Programming and Scripting

Rewriting file paths in XML file within bash script

Hi guys, I'm working on a large set of scripts to move files around several servers and manipulate them for our staff. Basically we're shooting things, the videos hit a server and then need organised due to the language they've been shot in. Our XML (designed for Apple's Final Cut Pro) is right... (6 Replies)
Discussion started by: omfgbunnies
6 Replies
Login or Register to Ask a Question