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.
Please don't change the posted scripts when you fix an error; it's very confusing. Better add an "EDIT: " line at the top of the post to let us know you have moved on from the posted script and post the new one in another post.
BTW, regards
Code:
read ANS
ANS = $ANS
Assignments must not have space either side of the = sign so you wanted ANS=$ANS except you don't because it doesn't do anything, IYSWIM.
i put that in so that we would know what the value of the ANS variable was in case it was not being assigned correctly.
i dont know, i dont use cases much. maybe a space between 1 and ) and 2 and ) like the ones above it ?
is it still complaining about line 119 ?
Ok i went back to original script with the latest help..
still chokin near bottom line 118
./123456789_fedora11: line 118: syntax error near unexpected token `newline'
./123456789_fedora11: line 118: `... '
Code:
1:#!/bin/bash
3:PLAYLIST=/home/Fedora11
5:AUDIOPATH=$PLAYLIST/MP3
7:## Functions for each task
9:create_playlist() {
11: cd "$AUDIOPATH"
12: echo -e "Enter Name Of Playlist --> \c"
13: read PNAME
14: touch $PNAME.m3u
16: echo -e
17: ls -v *.mp3
18: echo -e
19:}
23:edit_playlist() {
24: : put appropriate commands here
25:}
28:delete_playlist() {
29: : put appropriate commands here
30:}
33:generate_playlist() {
34: : put appropriate commands here
35:}
39:play_mp3() {
41: cd "$AUDIOPATH"
42: ls -v *.mp3
43: echo -e
44: echo -e "Please Select Your Song --> \c"
45: IFS= read DOG
46: mplayer "$AUDIOPATH"/$DOG
48:}
51:copy_mp3() {
53: cd "$AUDIOPATH"
54: ls -v *.mp3 >> "$AUDIOPATH"/tempdir.lst # Create Temp file with Directory listing
56: echo -e "Please Select Your Song To Copy --> \c"
57: read DONKEY
60: cat "$AUDIOPATH"/tempdir.lst | while read line; do #Read each line of the file and store the line to $line variable
61: ...
62: done < "$AUDIOPATH"/temp.lst
63: if [[ $line == $DONKEY ]]; then
64: echo "File Already Exist, Copy Aborted!"
65: else
66: cp $DONKEY "$PLAYLIST"/MP3_1
67: fi
68:
69: rm "$AUDIOPATH"/tempdir.lst # Delete the temporary file containing the directory listing
71:}
74:delete_mp3() {
76: cd "$AUDIOPATH"
77: ls -v *.mp3
78: echo -e
80: echo -e "Please Select Which Song To Delete --> \c"
81: read SONG
82: rm $SONG
83: cd "$AUDIOPATH" || exit 1
85:}
87:## Print menu and execute user's selection
89:while :
90:do
91: printf %s '
94:Mp3 Playlist Program:
95:================================
96:C)reate Mp3 Playlist
97:E)dit Mp3 Playlists
98:D)isplay Mp3 Playlists
99:G)enerate Mp3 Database
100:P)lay Mp3
101:1)Copy Mp3
102:2)Remove Mp3
103:Q)uit
104:Enter your selection ==> '
106: read ANS
107:debug: ANS= "$ANS"
108:...
109: case "$ANS" in
110: "c" | "C" ) create_playlist ;;
111: "e" | "E" ) edit_playlist ;;
112: "d" | "D" ) delete_playlist ;;
113: "g" | "G" ) generate_playlist ;;
114: "p" | "P" ) play_mp3 ;;
115: "o" | "O" ) copy_mp3 ;;
116: "l" | "L" ) delete_mp3 ;;
117: "q "| "Q" ) exit ;;
118:...
119:esac
120:done
Ok i went back to original script with the latest help..
still chokin near bottom line 118
./123456789_fedora11: line 118: syntax error near unexpected token `newline'
./123456789_fedora11: line 118: `... '
Code:
1:#!/bin/bash
3:PLAYLIST=/home/Fedora11
5:AUDIOPATH=$PLAYLIST/MP3
7:## Functions for each task
9:create_playlist() {
11: cd "$AUDIOPATH"
12: echo -e "Enter Name Of Playlist --> \c"
13: read PNAME
14: touch $PNAME.m3u
16: echo -e
17: ls -v *.mp3
18: echo -e
19:}
23:edit_playlist() {
24: : put appropriate commands here
25:}
28:delete_playlist() {
29: : put appropriate commands here
30:}
33:generate_playlist() {
34: : put appropriate commands here
35:}
39:play_mp3() {
41: cd "$AUDIOPATH"
42: ls -v *.mp3
43: echo -e
44: echo -e "Please Select Your Song --> \c"
45: IFS= read DOG
46: mplayer "$AUDIOPATH"/$DOG
48:}
51:copy_mp3() {
53: cd "$AUDIOPATH"
54: ls -v *.mp3 >> "$AUDIOPATH"/tempdir.lst # Create Temp file with Directory listing
56: echo -e "Please Select Your Song To Copy --> \c"
57: read DONKEY
60: cat "$AUDIOPATH"/tempdir.lst | while read line; do #Read each line of the file and store the line to $line variable
61: ...
62: done < "$AUDIOPATH"/temp.lst
63: if [[ $line == $DONKEY ]]; then
64: echo "File Already Exist, Copy Aborted!"
65: else
66: cp $DONKEY "$PLAYLIST"/MP3_1
67: fi
68:
69: rm "$AUDIOPATH"/tempdir.lst # Delete the temporary file containing the directory listing
71:}
74:delete_mp3() {
76: cd "$AUDIOPATH"
77: ls -v *.mp3
78: echo -e
80: echo -e "Please Select Which Song To Delete --> \c"
81: read SONG
82: rm $SONG
83: cd "$AUDIOPATH" || exit 1
85:}
87:## Print menu and execute user's selection
89:while :
90:do
91: printf %s '
94:Mp3 Playlist Program:
95:================================
96:C)reate Mp3 Playlist
97:E)dit Mp3 Playlists
98:D)isplay Mp3 Playlists
99:G)enerate Mp3 Database
100:P)lay Mp3
101:1)Copy Mp3
102:2)Remove Mp3
103:Q)uit
104:Enter your selection ==> '
106: read ANS
107:debug: ANS= "$ANS"
108:...
109: case "$ANS" in
110: "c" | "C" ) create_playlist ;;
111: "e" | "E" ) edit_playlist ;;
112: "d" | "D" ) delete_playlist ;;
113: "g" | "G" ) generate_playlist ;;
114: "p" | "P" ) play_mp3 ;;
115: "o" | "O" ) copy_mp3 ;;
116: "l" | "L" ) delete_mp3 ;;
117: "q "| "Q" ) exit ;;
118:...
119:esac
120:done
That's funny; running the above code (as lasted edited at 22:09) I got
Code:
c@CW8:~$ ./trash
./trash: line 58: syntax error near unexpected token `do'
./trash: line 58: `do'
Not surprising as there is no until, while or for line before the do.
60: cat "$AUDIOPATH"/tempdir.lst | while read line; do #Read each line of the file and store the line to $line variable
61: ...
@m2dmhot: what is line 108 and line 118 supposed to do (they contain ...) ?
also 107 should be: echo debug: ANS = "$ANS"
you need to clean up these ellipsises
we use them to describe code that comes before or after but is not pertinent to the current issue.
60: cat "$AUDIOPATH"/tempdir.lst | while read line; do #Read each line of the file and store the line to $line variable
61: ...
@m2dmhot: what is line 108 and line 118 supposed to do (they contain ...) ?
also 107 should be: echo debug: ANS = "$ANS"
you need to clean up these ellipsises
we use them to describe code that comes before or after but is not pertinent to the current issue.
51:copy_mp3() {
53: cd "$AUDIOPATH"
54: ls -v *.mp3 >> "$AUDIOPATH"/tempdir.lst # Create Temp file with Directory listing
56: echo -e "Please Select Your Song To Copy --> \c"
57: read DONKEY
60: cat "$AUDIOPATH"/tempdir.lst | while read line; do #Read each line of the file and store the line to $line variable
61: ...
62: done < "$AUDIOPATH"/temp.lst
63: if [[ $line == $DONKEY ]]; then
64: echo "File Already Exist, Copy Aborted!"
65: else
66: cp $DONKEY "$PLAYLIST"/MP3_1
67: fi
68:
69: rm "$AUDIOPATH"/tempdir.lst # Delete the temporary file containing the directory listing
71:}
I have a question regarding this script....
When I run this script, create a playlist. I get a 0 bytes m3u file. (contains nothing)
I read somewhere that there was an issue with mplayer and m3u files??? Maybe it was an older posting..
I could just have is save it as a .txt file?
^ line 17 doesnt redirect ls -v to the file name therefore it remains blank. m2dmhot hasnt gotten that for because s/he got other errors to worry about first.
@m2dmhot
in Perl6, the 3-character ellipsis is also known as the "yadda yadda yadda" operator and, similarly to its linguistic meaning, serves as a "stand-in" for code to be inserted later. http://en.wikipedia.org/wiki/Ellipsis
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.