Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
 
Reply to this topicStart new topic
> Simple script with cd, How to write a short script that cd into different directories
SuzuBell
post Nov 7 2012, 01:11 PM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 1
Joined: 7-November 12
Member No.: 17,941



Hello:

I am trying to write a script that cds into different directories to run a script (called code).

I wrote the script (called script) in a directory with this pathway (/projects):

#!/bin/bash

cd /projects/UNIVERSAL_A/
code
cd /projects/UNIVERSAL_B/
code
cd /projects/UNIVERSAL_C/
code

... and so on and so forth, for several more.

I know this is very basic, and poor programming that could be condensed, but that is not my question. ohmy.gif)

For now, I just want to run this script so that I do not have to manually repeat the process directly into the terminal. If I were to type the lines in the script above (minus the header line of #!/bin/bash), each step should work. However, after the script called code is initiated in each directory, it takes about 15 minutes to complete (and produces several files).

However, after performing the command (chmod 666 script), followed by the simple command (script), all that happens is I get a message (Script started, output file is typescript) and then the typescript file says (Script started on Wed Nov 7 11:56:17 2012).

I believe the program then terminates because otherwise there should be files produced in each directory as a result of the code running there each time taking about 15 minutes as well.

Any advice on the source of the problem? Thank you in advance!
Go to the top of the page
 
+Quote Post
michaelk
post Nov 7 2012, 05:44 PM
Post #2


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,800
Joined: 23-January 03
Member No.: 360



What linux distribution / version are you running?

Without knowing anything specific about your scripts it is impossible to know what is happening. 666 permissions is only read/write for all. To make your script executable for all then you 777.

/www.tuxfiles.org/linuxhelp/filepermissions.html
Go to the top of the page
 
+Quote Post
mogwin
post Nov 21 2012, 10:30 AM
Post #3


Whats this Lie-nix Thing?
*

Group: Members
Posts: 6
Joined: 21-November 12
Member No.: 17,973



The problem is that there is a system command called /usr/bin/script. That one is showing up first in your $PATH so it's being called.

The best solution is to change the name of your script to something unique to avoid the conflict.

You can also fully path your script by running it with "./script"
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 20th November 2017 - 02:21 PM