LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 01-07-2021, 12:27 PM   #1
Arch4GoodieLike
Member
 
Registered: Sep 2020
Location: Cave
Distribution: Arch Linux
Posts: 143

Rep: Reputation: Disabled
Question [question] Bash Script from Github not working


I found this interesting Bash-Snippets from Github. I downloaded it with the [code] button and extracted it manually. The "meme" bash outputs a jpg which is, corrupt and can't be viewed therefore. I checked the code but still can't pinpoint the reason, why it isn't working. I tried multiple PhotoViewer tools. For usage, i tried
Code:
$ ./meme -f test #outputs the filename as "test.jpg"
$ doge #background
$ Topline #toplineText
$ Bottomline #BottomlineText
The other bashes, which i can profit from, are all functional, out of the box.

Question: Anyone knows the reason, why the script isn't working on my side?

Last edited by Arch4GoodieLike; 01-07-2021 at 01:50 PM.
 
Old 01-07-2021, 12:41 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Just sharing or was there a particular question?
 
Old 01-07-2021, 01:23 PM   #3
Arch4GoodieLike
Member
 
Registered: Sep 2020
Location: Cave
Distribution: Arch Linux
Posts: 143

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rtmistler View Post
Just sharing or was there a particular question?
If you have nothing helpful to say, then go along. Simple as that.
 
1 members found this post helpful.
Old 01-07-2021, 02:20 PM   #4
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,137
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
That's a bunch of scripts.
This one.
https://github.com/alexanderepstein/...ster/meme/meme

Code:
usage()
{
  cat <<EOF
Meme
Description: A lightning fast meme generator
Usage: tool [flags] or tool [flags] [arguments]
  -u  Update Bash-Snippet Tools
  -h  Show the help
  -f  Choose the output filename
  -v  Get the tool version
Examples:
   meme -h
   meme -f dogeMeme
EOF
}
Looks like it is suppose to do this
Code:
httpGet "https://memegen.link/$bg/$first/$second.jpg" >> "$fileName".png
Lets see:
Code:
agent="Mozilla/5.0 (Windows NT 10.1; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0"

curl -A "$agent" https://memegen.link/dog/cat/test.jpg -o test.jpg
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
Looks like it needs to be this
https://api.memegen.link/images/dog/cat/test.jpg

It redirects, this will get it.
Code:
curl -LA "$agent" https://memegen.link/dog/cat/test.jpg -o test.jpg
Go ahead and fix that script if you want to.
 
1 members found this post helpful.
Old 01-07-2021, 02:35 PM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Excuse the brief confusion Arch4GoodieLike, until you edited your original, it was unclear what the particular problem was, although there were some clues.

I agree that teckk has it covered fairly well and suggest if you desire to modify the httpGet() function cited and try to create the meme.

An additional thing you can do if you continue to see problems, is to put a "set -xv" line just after the first line of the script. This will enable verbose and debug output when you run the script, you should see how the script progresses through the main and functions and see the detailed output if there are additional errors.
 
Old 01-07-2021, 03:18 PM   #6
Arch4GoodieLike
Member
 
Registered: Sep 2020
Location: Cave
Distribution: Arch Linux
Posts: 143

Original Poster
Rep: Reputation: Disabled
[QUOTE=teckk;6205162
Go ahead and fix that script if you want to.[/QUOTE]

the little one-liner trick of yours does it!
I added "api." to this line:
Code:
httpGet "https://api.memegen.link/$bg/$first/$second.jpg" >> "$fileName".png || return 1
and it's still not working if i try it scriptwise.
 
Old 01-07-2021, 03:23 PM   #7
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,137
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
No, Look at line 24
Code:
httpGet()
{
  case "$configuredClient" in
    curl)  curl -A curl -s "$@" ;;
    wget)  wget -qO- "$@" ;;
    httpie) http -b GET "$@" ;;
    fetch) fetch -q "$@" ;;
  esac
}
 
  


Reply

Tags
bash, github



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Github no binaries /easy downloads without login? Github noob rico001 Linux - Software 4 01-02-2021 07:14 AM
LXer: GitHub Actions moves GitHub into DevOps LXer Syndicated Linux News 0 08-09-2019 01:04 PM
LXer: Learn to use GitHub with GitHub Learning Lab LXer Syndicated Linux News 0 04-20-2018 01:12 AM
LXer: GitHub wants more new contributors, because that's what GitHub is for LXer Syndicated Linux News 0 07-27-2017 06:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration