Where is my error in this alias?

sofasurfer

Active Member
Joined
May 24, 2022
Messages
168
Reaction score
58
Credits
1,425
Here is my alias
Code:
alias vidlplaylist='echo -n "enter url: " && read url && echo -e "$(date)" "${url}\n" >> ~/vidl-history && cd Downloads; yt-dlp --ffmpeg-location /usr/bin $url'

I put it in the .bashrc file. When I run $ source ~/.bashrc I get
Code:
$ source ~/.bashrc
bash: /home/daryl/.bashrc: line 137: unexpected EOF while looking for matching `''
bash: /home/daryl/.bashrc: line 138: syntax error: unexpected end of file

Where is my problem?
 


Look like lines 137 and 138 to me

bash: /home/daryl/.bashrc: line 137: unexpected EOF while looking for matching `''
bash: /home/daryl/.bashrc: line 138: syntax error: unexpected end of file

line 137 is telling you are missing a "
 
The error look like it's not on the line you shared but on line 137.
Is this line 137?
Yes this is line 137. I put the alias at the bottom of this file. I do not have a line 138...is that my problem.
Look like lines 137 and 138 to me

bash: /home/daryl/.bashrc: line 137: unexpected EOF while looking for matching `''
bash: /home/daryl/.bashrc: line 138: syntax error: unexpected end of file

line 137 is telling you are missing a "
This alias is copied directly from the .bashrc file and I do not see a missing ". Do you?
P.S. Its looking for a missing ' , not a ".
 
The above alias will download a playlist. I have another alias that downloads just one video and it has given me no trouble. Here are both aliases for comparison.

Code:
# My edit to download a video as is and store video url and name in /video-history
alias vidl='echo -n "enter url: " && read url && echo -e "$(date)" "${url}\n" >> ~/vidl-history && cd Downloads; yt-dlp --ffmpeg-location /usr/bin $url'

Code:
# ALIAS TO DOWNLOAD A PLAYLIST
alias vidlplaylist='echo -n "enter url: " && read url && echo -e "$(date)" "${url}\n" >> ~/vidl-history && cd Downloads; yt-dlp --ffmpeg-location /usr/bin $url'

Do you see any difference?
 
I found the problem. I deleted my script and when I ran $ source ~/.bashrc I still got the error on the lines of another script. I found that in a previous script I had created I left the final ' (apostrophe) off at the end of the code after the * (asteresk)
Code:
alias dtrash='cd /root/.local/share; sudo rm -rf Trash*;sudo rm -rf ~/.local/share/Trash/*'
Everything works fine now...except I am getting a ton of these
Code:
HTTP Error 400: Bad Request. Retrying (2/3)...
[youtube] IoFCIzAft6s: Downloading android player API JSON
Any ideas? In the end I still am getting the downloads I want errors or not.
 
In case of an alias, first thing to try is to run the aliased command itself, fully. You would have noticed it would run OK.
So, then you know the issue is in the alias command, and that's not a lot because at the right hand side, it's just a single quote. :)

If the full command wouldn't have run, I would run each of the ; command separated commands one-by-one, in the correct order, and note if each work or not.

For example:
alias dtrash='cd /root/.local/share; sudo rm -rf Trash*;sudo rm -rf ~/.local/share/Trash/*'

debug like this:
cd /root/.local/share
sudo rm -rf Trash*
sudo rm -rf ~/.local/share/Trash/*
 
Those are server side errors. Error 400 means that the server is not understanding the request. It could be that you’ve used an incorrect URL, or it could be a corrupted session cookie, or a DNS related problem.
If it’s a bad URL, you’ll need to double check it.
If it’s a cookie/DNS issue, then clearing your browsers cookies and clearing your DNS cache should fix the problem.

If the problem self-corrects after a couple of attempts, you could perhaps opt to redirect errors to /dev/null in your alias.
 

Staff online

Members online


Latest posts

Top