Uli101 assignment 2

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Uli101 assignment 2
# 1  
Old 12-02-2010
Uli101 assignment 2

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:

# Create a BASH shell script called momo (My Own Music Organizer)
# in ~/uli101.a2/ directory according to the following specifications:"

# Your script will be used to organize a collection of MP3 files.
# Files to be processed are expected to reside in a single directory
# (no sub-directories).
# Your script, must create subdirectories for each artist and
# create symbolic links to each song in appropriate directories.


2. Relevant commands, code, scripts, algorithms:
I know you have to use VI editor to create a bash file,
i dont get where to start for the first part i tried a lot of stuff.



3. The attempts at a solution (include all code and scripts):
I could not get the first part i attempted it, the creating symbolic links to each song
i believe that is ln and for the soft links i would use ln -s i am gonna attempt to try that part. For the first part i started off with vi momo in my uli101.a2 folder.
i created parent directories which were completely wrong.


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Seneca college, Toronto, Canada, Tanvir Alam, Uli101

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
# 2  
Old 12-02-2010
Can we see what you tried so far?

Yes vi is a good start for creating/editing you bash script...

The first thing is to be sure you understand what is been asked...
Then to describe the task in your words, once every thing is clear, it is time to think how it can be done - with what commands etc..

Your first task after doing a man vi, will be to read the man pages of the commands you think you will need, yes ln, but also mkdir...

We have no idea with the information you give how you will be able to recognize the artist...
# 3  
Old 12-10-2010
...

have u been able to solve this assignment?

---------- Post updated at 11:53 PM ---------- Previous update was at 11:53 PM ----------

I'm trying the same assignment but I keep getting a exit error.
# 4  
Old 12-10-2010
I'm doing this same assignment but I keep getting this error.

Testing your script for execution without arguments...
- Exit status is: Incorrect
HINT: Test for that and exit with status code 1 on error

I'm in desperate need of help, anyone please?
# 5  
Old 12-10-2010
There is no script to see what error you have...
@tcindy:
Code:
tag=$(tail -c 128 $path)

bad...
Code:
TAG=$(echo $PATH|tail -c64)

good...
Q: Why dont you test line by line to see why you have errors? Here your first initialization doesn't work:
(bash on aix6.2...)
Code:
 $ tail -c 32 $PATH
/usr/bin:/usr/dt/bin:/usr/dt/contrib/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/usr/lbin:/sbin:/usr/local/bin:/usr/vac/bin:/opt/freeware/bin:/opt/sas/9.2/SASFoundation/9.2:/usr/java5/bin:/usr/java5/jre/bin:/prd/app/menu:/prd/app/utl:/home/vbe/scripts:/home/vbe/bin:.: A file or directory in the path name does not exist.
an12:/sm/cron/bin $ tail -c64 < $PATH
bash: /usr/bin:/usr/dt/bin:/usr/dt/contrib/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/usr/lbin:/sbin:/usr/local/bin:/usr/vac/bin:/opt/freeware/bin:/opt/sas/9.2/SASFoundation/9.2:/usr/java5/bin:/usr/java5/jre/bin:/prd/app/menu:/prd/app/utl:/home/vbe/scripts:/home/vbe/bin:.: A file or directory in the path name does not exist.
an12:/sm/cron/bin $ TAG=$(echo $PATH|tail -c64)
an12:/sm/cron/bin $ echo $TAG
in:/prd/app/menu:/prd/app/utl:/home/vbe/scripts:/home/vbe/bin:.

# 6  
Old 12-10-2010
I'll show you the code that's given to us as a guideline.

Code:
# Create a BASH shell script called momo (My Own Music Organizer)
# in ~/uli101.a2/ directory according to the following specifications:"

# Your script will be used to organize a collection of MP3 files.
# Files to be processed are expected to reside in a single directory
# (no sub-directories).
# Your script, must create subdirectories for each artist and
# create symbolic links to each song in appropriate directories.

# The script usage will be as follows:
# momo source_directory [destination directory]

# If the destination directory is not provided, the present working directory
# is the destination.
# The name of the file/link will be based on album and song name
# in the following format: Album - SongTitle.mp3

# Additional information:
# - All song metadata will be based on information in ID3v1 tags
# - Assume that all .mp3 files in the source directory have a valid ID3v1 tag
#   (ID3v1 details can be found on-line: http://en.wikipedia.org/wiki/ID3#ID3v1)
# - .mp3 extensions can have any combination of upper- and lower-case letters
# - Assume that you have read permission for the source directory
#   and write permission for destination
# - Ignore files in the source directory that do not have the .mp3 extension
# - Display an error message and exit with status 1 if no parameters are given
# - Display an error message and exit with status 2 if source is not a directory
# - Display an error message and exit with status 3 if destination
#   does not exist or is not a directory

# TIP: Keep a secure backup of your script outside of other users' access.

# Practice files can be found on matrix in ~uli101/public/songs[1-5]
# directories.  Although they are not actual mp3 files, they contain
# valid ID3v1 tags.

# In addition to creating a directory/file structure, your script must create
# a valid XHTML report file containing the output of the tree command,
# showing the above structure. The report will also show a footer section
# showing the source directory path, date/time when report was created
# and number of artist and songs organized.

# A sample report is available: https://cs.senecac.on.ca/~fac/uli101/momo.html

# Place the report file in the output directory and call it: .songs.html
# Use the Courier typeface throughout the page and set the text colour to
# 0011 0011 0110 0110 1001 1001 using hexadecimal numbers.
# Pick a background colour that contrasts well with your text colour.
# Do not just use white for background.

# TIP: Have a dedicated testing directory for output and make a symbolic link
# in your ~/public_html directory to your report file in there.
# This way it will be easy to view and validate the report using your browser.

# Your script will produce a single line of output to the shell
# (other than possible error messages), containing two numbers, separated by
# a single space: number of artists processed and number of songs processed.

# Check your progress using the following command: uli101.a2.check
# Submit your completed assignment using the following command: uli101.a2.submit

# PLEASE NOTE THAT PLAGIARISM CASES WILL BE HANDLED ACCORDING TO THE ACADEMIC
# POLICY. YOUR SCRIPT MUST BE WRITTEN WITHOUT HELP FROM OTHERS AND YOU ARE NOT
# ALLOWED TO ACCESS OTHER STUDENTS' ASSIGNMENTS
# DO NOT SHARE YOUR SOLUTION. ASK ONLY YOUR PROFESSOR FOR HELP.

### TO DO: Check if at least one parameter is supplied, exit on error
if [ $# ]
then
        exit
fi

### TO DO: Check if first parameter is a directory, exit on error

# Set the destination to default (pwd) if no destination is provided
if [ $# -lt 2 ]
then
        set "$1" .
fi

### TO DO: Check if destination exists and is a directory, exit on error

for path in $(### TO DO: Get the list of mp3 files in the source directory)
do
        # Extract the ID3 TAG from file
        tag=$(tail -c 128 $path)

        # Extract the song name and trim space padding
        song_name=$(echo "$tag" | cut -c 4-33 | sed -r 's/ +$//')

        ### TO DO: Extract the artist and album, trim both
        ### TO DO: Create a directory for artist in the destination directory
        ### (if not already there)
### TO DO: Create a symbolic link to the song in the artist's directory
done

### TO DO: Finish the output line to the terminal
echo

cat << TOP > $2/### TO DO: Set the report file name here
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
        <title>ID3 Report Page</title>

        ### TO DO: Display the tree for the artists/songs directory structure

        <style type="text/css">
        ### TO DO: Set the font typeface for the entire report page as assigned
        ### TO DO: Set the font colour for the entire page as assigned
        ### TO DO: Set the report background to a colour of your choosing
        </style>
</head>
<body>
        <h2>ID3 Report Page</h2>
TOP

### TO DO: Add the path to the source directory to the report
### TO DO: Add current date/time to the report
### TO DO: Add to the report how many artists and songs were processed
### TO DO: Add the W3C XHTML Validator link and icon to the report
### TO DO: Add the W3C CSS Validator link and icon to the report

echo "</body></html>" >> $2/### TO DO: Set the report file name here

Seneca College, ULI101, Lloyd Parker

---------- Post updated at 11:22 AM ---------- Previous update was at 11:15 AM ----------

I've done the first part. I'm extremely stuck on the error part, Idk what to put because whenever I do a check it gives me the error I posted above. I'm in desperate need of help, anyone who can help is a God send! Thank you

---------- Post updated at 11:40 AM ---------- Previous update was at 11:22 AM ----------

For this part of the code:
Code:
for path in $(### TO DO: Get the list of mp3 files in the source directory)
do
        # Extract the ID3 TAG from file
        tag=$(tail -c 128 $path)

        # Extract the song name and trim space padding
        song_name=$(echo "$tag" | cut -c 4-33 | sed -r 's/ +$//')

        ### TO DO: Extract the artist and album, trim both
        ### TO DO: Create a directory for artist in the destination directory
        ### (if not already there)
### TO DO: Create a symbolic link to the song in the artist's directory
done

I have attempted this, Idk if it's right though.
Code:
for path in $1 ls .*[mM][pP]3
do
        tag=$(tag -c 128 $path)

        song_name=$(echo "$tag" | cut -c 4-33 | sed -r 's/ +$//')
        artist=$(echo "$tag" | cut -c 34-63 | sed -r 's/ +$//')
        album=$(echo "$tag" | cut -c 64-93 | sed -r 's/ +$//')
done

filename="$artist" - "$song_name".mp3

if [ ! -d "$2/$artist" ]
        mkdir "$2/$artist"
fi

ln -s $tag $filename

# 7  
Old 12-10-2010
Code:
for path in $1 ls .*[mM][pP]3
do
        tag=$(tail -c 128 $path)

Look at this code, why dont you test it yourself, you will see that "tag=$(tail -c 128 $path)" is syntaxly wrong, look at the man pages of tail, look at my previous output!
I will give you a hint:
When desperate, I echo every new part of instruction in a program with references sso I know where I am in the program and display all the variables (using echo ). This is the only way you can see if you have the expected output

(DId you go to the end of lines of my previous post to see the words displayed in bold?)
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Need a little help with assignment

Hello all im currently working on this assignment and a little stump on how to check for an argument heres the instructions: Step 4: Modify your script so that if there is an argument called TestError you display the following error message with your usage statement. TestError found Example:... (1 Reply)
Discussion started by: bsn3971
1 Replies

2. Homework & Coursework Questions

Help Assignment !! :D

Q-1 Write a shell script in Unix that lists files from your current working directory · By modification time when called with lm · By access time when called with la. By default, the script should show the listing of all the files in the current directory. Q-2 Write a shell script which... (1 Reply)
Discussion started by: Vishank Parikh
1 Replies

3. Shell Programming and Scripting

Help Assignment !! :D

Q-1 Write a shell script in Unix that lists files from your current working directory · By modification time when called with lm · By access time when called with la. By default, the script should show the listing of all the files in the current directory. Q-2 Write a... (1 Reply)
Discussion started by: Vishank Parikh
1 Replies

4. Homework & Coursework Questions

Assignment Help

1. List commands to create the directory hierarchy $HOME/a/b/c in vi to replace all occurences of TMP with tmp in lines 1 through 10 in vi to replace first occurence of CPU_file with DISK_file at line 15 2. Explain with a very simple example, usage of "ls -a" 3. What do the... (2 Replies)
Discussion started by: jessesaini
2 Replies

5. Homework & Coursework Questions

could really use some help! Uli101 assignment 2

Continue here (0 Replies)
Discussion started by: vpundit
0 Replies

6. Shell Programming and Scripting

Help with variable assignment

Hi, In AIX I have a variable with , (coma) separated values assigned to it like shown below var1=apple,boy,chris i want to convert this to var1='apple','boy','chris' the number of values assigned to var1 might change and it could be from 1 to n any suggestions please? (3 Replies)
Discussion started by: rahul9909
3 Replies

7. Shell Programming and Scripting

RE value assignment

Hi all How do I assign a pattern to a variable after a match is found using a regular expression in PERL? For example using a regular expression (RE) and matching as given if ($_ =~ /(?:\s*+\s*,)*\s*+\s*/) I want to assign the pattern matched by the RE to a variable. e.g. given the... (4 Replies)
Discussion started by: my_Perl
4 Replies

8. What is on Your Mind?

New Assignment

All Sys Administrators, With due respect I would like to know what should be BEST Things to do when LEAVING one job , and what Precaution MUST be taken while taking over new JOB?? Please Discuss in detail the STEP to be taken for both the TIME ?? (3 Replies)
Discussion started by: vakharia Mahesh
3 Replies

9. UNIX for Dummies Questions & Answers

how to do my assignment?????

my lecturer want to do an assignment about telnet server..first, he want us to download the telnet server..then he want we do about copy files and share files by using the telnet server....what is that??? and one more thing is how to do 'ping'???? (1 Reply)
Discussion started by: amelia
1 Replies
Login or Register to Ask a Question