Automating Linux Script


 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Automating Linux Script
# 1  
Old 09-23-2013
Automating Linux Script

1. The problem statement, all variables and given/known data:
I want to automate the creation or processing of the following:
  • Directory and subdirectory creation for your scenario company
  • Files in each of the directories
  • Symbolic links from 2 subdirectories to their parent directories
  • Setting appropriate file permissions for the directories and files:
    • Directories
      • the file owner can read, modify and access the scenario company directories,
      • the group members can read and access the scenario company directories,
      • everyone else has no access.
    • Files
      • The owner can read and modify the file,
      • the group members can only read the file
      • everyone else has no permissions at all.
  • Include branching to only execute the directory, file and link commands only if the directory or file does not already exist.
  • Set up an error log file with commands to route the errors messages into it.
However, I have only been using Linux for a few weeks now and this is proving to be extremely complicated. I have read tutorials on automating but cannot understand it. This is a school assignment due today by 11:59pm central time. Any assistance would be greatly appreciated!


2. Relevant commands, code, scripts, algorithms:
Here is the script that I have completed through my previous assignments, it the base script that they want us to automate.
Code:
 \KGS_Home\
  Testing \+
  |- Beta
  |- DLC
  |- IndyGames
  Programming \+
  |- MainStory
  |- SideStory
  |- CharacterStats
  ArtDesign \+
  |- CoverArt
  |- Background
  |- Characters
  Marketing \+
  |- Trailers
  |- Demos
  |- Posters
  
  
  mkdir -v \KGS_Home
  cd KGS_Home
  mkdir \Testing
  mkdir \Programming
  mkdir \ArtDesign
  mkdir \Marketing
  cd Testing
  mkdir \Beta
  mkdir \DLC
  mkdir \IndyGames
  cd ..
  cd Programming
  mkdir \MainStory
  mkdir \SideStory
  mkdir \CharacterStats
  cd ..
  cd ArtDesign
  mkdir \CoverArt
  mkdir \Background
  mkdir \Characters
  cd ..
  cd Marketing
  mkdir \Trailers
  mkdir \Demos
  mkdir \Posters
  cd..
  ln -s \Testing\Beta \Beta
  ln -s \Testing\DLC \DLC
  ln -s \Testing\IndyGames \IndyGames
  ln -s \Programming\MainStory \MainStory
  ln -s \Programming\SideStory \SideStory
  ln -s \Programming\CharacterStats \CharacterStats
  ln -s \ArtDesign\CoverArt \CoverArt
  ln -s \ArtDesign\Background \Background
  ln -s \ArtDesign\Characters \Characters
  ln -s \Marketing\Trailers \Trailers
  ln -s \Marketing\Demos \Demos
  ln -s \Marketing\Posters \Posters
  chmod 750 –R /Testing
  chmod 750 –R /Programming
  chmod 750 –R /ArtDesign
  chmod 750 –R /Marketing
  touch Testing/TestingFile
  touch Programming/ProgrammingFile
  touch ArtDesign/ArtDesignFile
  touch Marketing/MarketingFile
  chmod 740 –R Testing/TestingFile
  chmod 740 –R Programming/ProgrammingFile
  chmod 740 –R ArtDesign/ArtDesignFile
  chmod 740 –R Marketing/MarketingFile


3. The attempts at a solution (include all code and scripts):
I have been unable to make any attempts because my professor neglected to explain how to automate at all. I have researched the topic but found little to no definitive results.


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Colorado Technical University Online, Colorado, USA, Majid Mohammad, CS126-1303B-04 : Unix Fundamentals

Last edited by vbe; 09-23-2013 at 01:32 PM..
# 2  
Old 09-23-2013
What you want to do is unclear to me...
Are these backslashes artefacts? if not what OS are you using with which shell? For its not very UNIX to me...
What should I understand by:
Code:
 \KGS_Home\
  Testing \+
  |- Beta
  |- DLC
  |- IndyGames
  Programming \+
  |- MainStory
  |- SideStory
  |- CharacterStats
  ArtDesign \+
  |- CoverArt
  |- Background
  |- Characters
  Marketing \+
  |- Trailers
  |- Demos
  |- Posters

What do you understand by automating?
# 3  
Old 09-23-2013
What I provided was the contents of a Vi file my instructor wanted me to make. The section you are asking about is simply a showing of by home directory for an imaginary company and its directories and sub-directories. That is simply to show how they connect to each other. What I am trying to automate is the process of creating those directories and sub-directories on various company computers without having to type everything out for each computer.
# 4  
Old 09-23-2013
So we agree looking at what you posted could be used as a basic script to create what you want, optimizing the code as it is is waste of time ( like using mkdir -p ..)
You could maybe save a couple of lines in the chmod process, that is going at a higher level and use -R 755 * and -R 740 [TPAM]*/*File
Put all that in script and make it executable then it is just copying your script to the new computers and executing it or you may look at the command rdist and see if you will not use its facilites...
# 5  
Old 09-23-2013
What would -R 755 * and -R 740 [TPAM]*/*File do exactly?

---------- Post updated at 01:23 PM ---------- Previous update was at 01:22 PM ----------

I just looked into rdist but it looks like that isn't something my instructor intends for us to use

Last edited by Scott; 09-23-2013 at 03:35 PM.. Reason: Code tags
# 6  
Old 09-23-2013
chmod -R 755 * would recursively change every file and directory in the current directory (except anything beginning with a . (dot) in the current directory) to have permissions rwxr-xr-x.

chmod -R 740 [TPAM]*/* would recursively change every file and directory in any directory beginning with "T", "P", "A" or "M" in the current directory (except any file or directory beginning with . (dot) in exactly the directory beginning with "T", "P", "A" or "M" in the current directory) to have a permission of rwxr-----.

Code:
$ mkdir Tx Px Ax Mx              

$ touch Tx/.T1 Px/P1 Ax/.Ax Mx/Mx

$ find . -ls
2138774        0 drwxr-xr-x    6 scott            staff                 204 Sep 23 20:48 .
2139783        0 drwxr-xr-x    3 scott            staff                 102 Sep 23 20:48 ./Ax
2139820        0 -rw-r--r--    1 scott            staff                   0 Sep 23 20:48 ./Ax/.Ax
2139784        0 drwxr-xr-x    3 scott            staff                 102 Sep 23 20:48 ./Mx
2139821        0 -rw-r--r--    1 scott            staff                   0 Sep 23 20:48 ./Mx/Mx
2139782        0 drwxr-xr-x    3 scott            staff                 102 Sep 23 20:48 ./Px
2139819        0 -rw-r--r--    1 scott            staff                   0 Sep 23 20:48 ./Px/P1
2139781        0 drwxr-xr-x    3 scott            staff                 102 Sep 23 20:48 ./Tx
2139818        0 -rw-r--r--    1 scott            staff                   0 Sep 23 20:48 ./Tx/.T1

$ chmod -R 740 [TPAM]*/*

$ find . -ls            
2138774        0 drwxr-xr-x    6 scott            staff                 204 Sep 23 20:48 .
2139783        0 drwxr-xr-x    3 scott            staff                 102 Sep 23 20:48 ./Ax
2139820        0 -rw-r--r--    1 scott            staff                   0 Sep 23 20:48 ./Ax/.Ax
2139784        0 drwxr-xr-x    3 scott            staff                 102 Sep 23 20:48 ./Mx
2139821        0 -rwxr-----    1 scott            staff                   0 Sep 23 20:48 ./Mx/Mx
2139782        0 drwxr-xr-x    3 scott            staff                 102 Sep 23 20:48 ./Px
2139819        0 -rwxr-----    1 scott            staff                   0 Sep 23 20:48 ./Px/P1
2139781        0 drwxr-xr-x    3 scott            staff                 102 Sep 23 20:48 ./Tx
2139818        0 -rw-r--r--    1 scott            staff                   0 Sep 23 20:48 ./Tx/.T1

# 7  
Old 09-23-2013
Thank you Scott, I understand that now. But how will I automate everything in my script?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Automating Linux Script

I want to automate the creation or processing of the following: Directory and subdirectory creation for your scenario company Files in each of the directories Symbolic links from 2 subdirectories to their parent directories Setting appropriate file permissions for the directories and... (1 Reply)
Discussion started by: ekglag2
1 Replies

2. Shell Programming and Scripting

Automating Crontab through script??

is it possible to automate crontab through script... I ll be getting the data i.e. cron entries from DB. (5 Replies)
Discussion started by: nikhil jain
5 Replies

3. Shell Programming and Scripting

automating a perl script

Hi, I have a perl script that takes in 2 numerical values as ARGV. perl script.pl parameter1 num1 num2 in my case I have 1000's of num1 and num2. I can have them in separate files. Please let me know how to automate this run using shell scripting or using awk, so that I don't have to... (4 Replies)
Discussion started by: Lucky Ali
4 Replies

4. Shell Programming and Scripting

Help with automating a bash script

Hi Guys, There are some emails going deferred as we got some new IP's from our ISP. So I was trying to manually copy the deferred mail and forward it to our sales team so that they can contact our client. I am new to this script thing, but luckily I was able to write the code to extract the data... (1 Reply)
Discussion started by: linuxrulz
1 Replies

5. Shell Programming and Scripting

Automating A Perl Script over a database

Dear Scripting Gods I've never done shell scripting before and have only recently got to grips with Perl, so apologies for my naivity. I've written a perl program which takes in two files as arguments (these are text documents which take in the information I need) The perl program spits out a... (1 Reply)
Discussion started by: fraizerangus
1 Replies

6. Shell Programming and Scripting

Automating Interactive script

I have a script that will install software on all remote host. At the end of the script it starts the install.sh part and goes into a interactive mode asking Yes or No questions and prompting to add a username and password. My question is how can I script this so that these questions are... (7 Replies)
Discussion started by: soupbone38
7 Replies

7. Shell Programming and Scripting

Help in automating dates in ksh script

I need to run a command at the end of a backup job and this command will produce a report of what my backup jobs have collected in the previous day. The real problem is that this binary works with absolute dates only, so I should have to modify the script every single time I need it to work. It... (1 Reply)
Discussion started by: italia1971luca
1 Replies

8. UNIX for Dummies Questions & Answers

cron ? automating a script

Hi all. basically i need to run a script every 30 minutes. my script is simply an error report: errpt thats it, is there anyway to make this happen every 30 minutes without having to type errpt in, the script will get bigger as i add more things to do but just need to know how to... (8 Replies)
Discussion started by: hassanj
8 Replies

9. Shell Programming and Scripting

Automating Logform Command in a script

Hi all I am trying to create a script to automate the creating of filesystems. The problem I am having is as follows:- After creating the Log Logical Volume, I want to format it, using the logform command. The Logform command expects user intervention, by typing 'y' and 'enter' to continue.... (2 Replies)
Discussion started by: TheDoc
2 Replies

10. Shell Programming and Scripting

automating sftp script

I have to write an automated sftp script which uses password authentication method to access the remote server. I want to pass the password as a parameter or to be included in the script itself, so that when i run the sftp script, it should not prompt me to enter the password. Thanks in advance... (1 Reply)
Discussion started by: Rajeshsu
1 Replies
Login or Register to Ask a Question