This media is not supported in your browser
VIEW IN TELEGRAM
play - TUI playground for your favorite programs, such as grep, sed and awk
https://redd.it/174rsd6
@r_bash
https://redd.it/174rsd6
@r_bash
Help Moving files in a directory (SCRIPT)
Hey y'all, im trying to learn Bash noscripting and figured i'd start with something that will be useful to me.
Objective: Allow users (me) to be able to select which source + destination to move files from and to. The goal is to be able to run the noscript and move everything in my downloads folder to wherever i may want it. But i also want to be able to do this with any directory.
​
#!/bin/bash
echo Can you show me where the source directory is?
read source
echo $source is the source directory. What is the Destination directory?
read dest
cd $(echo $source)
ls
pwd
mv -v $dest
If i replace $dest with the file path instead of using the variable created by "read" then it works flawlessly. I tried to add $HOME as a prefix to $data but that wasn't working.
​
mv -v ~/Documents
Any tips would be greatly appreciated as i am new to noscripting and fairly new to linux. TIA
https://redd.it/174zmfv
@r_bash
Hey y'all, im trying to learn Bash noscripting and figured i'd start with something that will be useful to me.
Objective: Allow users (me) to be able to select which source + destination to move files from and to. The goal is to be able to run the noscript and move everything in my downloads folder to wherever i may want it. But i also want to be able to do this with any directory.
​
#!/bin/bash
echo Can you show me where the source directory is?
read source
echo $source is the source directory. What is the Destination directory?
read dest
cd $(echo $source)
ls
pwd
mv -v $dest
If i replace $dest with the file path instead of using the variable created by "read" then it works flawlessly. I tried to add $HOME as a prefix to $data but that wasn't working.
​
mv -v ~/Documents
Any tips would be greatly appreciated as i am new to noscripting and fairly new to linux. TIA
https://redd.it/174zmfv
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Does going through the entire noscript just to find the help function slow down noscript?
My noscript looks like this
Help function
All the other functions
My reasoning is that if the user just wants to use the -h flag then the noscript shouldn't pass through all the main functions which aren't going to be used. But having the help function at the beginning looks ugly in my noscript so I want to move it down. But then the noscript (I think) would have to read through all the main functions which aren't going to be used which would slow down the noscript.
​
https://redd.it/1753fda
@r_bash
My noscript looks like this
Help function
All the other functions
My reasoning is that if the user just wants to use the -h flag then the noscript shouldn't pass through all the main functions which aren't going to be used. But having the help function at the beginning looks ugly in my noscript so I want to move it down. But then the noscript (I think) would have to read through all the main functions which aren't going to be used which would slow down the noscript.
​
https://redd.it/1753fda
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
ssh user maker
Guys, I’ve created a bash noscript for creating ssh users on server with expire date,and speed limit, would be happy if you check it out and tell me your feedbacks, feel free to commit to it and if it have any problems please let me know.
Btw README file was generated by ChatGPT.
https://github.com/momalekiii/sshmaker
https://redd.it/175gqvy
@r_bash
Guys, I’ve created a bash noscript for creating ssh users on server with expire date,and speed limit, would be happy if you check it out and tell me your feedbacks, feel free to commit to it and if it have any problems please let me know.
Btw README file was generated by ChatGPT.
https://github.com/momalekiii/sshmaker
https://redd.it/175gqvy
@r_bash
GitHub
GitHub - momalekiii/sshmaker: Simple noscript for create ssh users and manage usage.
Simple noscript for create ssh users and manage usage. - GitHub - momalekiii/sshmaker: Simple noscript for create ssh users and manage usage.
This media is not supported in your browser
VIEW IN TELEGRAM
[Help] tput setab colors stretch to terminal width on term scroll. (noscript in comments)
https://redd.it/175m914
@r_bash
https://redd.it/175m914
@r_bash
Building options from array. What am I doing wrong?
I am trying to find a range of files, but I want to be able to keep the extensions in an array. I try to echo the final find command and it echos correctly, but if I try run it, I just get a null result. Copy and pasting the echoed command returns a result.
#!/bin/bash
extarray=( "3gp" "mp4" "mkv" "m4a" "webm" "mpg" "mpeg" "avi" "vob" "asf" "wmf" )
for ((n=0; n<${#extarray@}; n++))
do
if [ $n == "0" ]
then
optiname="-iname \".${extarray[$n]}\""
else
temp=$optiname
optiname="$temp -o -iname \".${extarray$n}\""
fi
done
echo "find . -type f \( $optiname \) | sort"
find . -type f \( "$optiname" \)
​
https://redd.it/1760ifx
@r_bash
I am trying to find a range of files, but I want to be able to keep the extensions in an array. I try to echo the final find command and it echos correctly, but if I try run it, I just get a null result. Copy and pasting the echoed command returns a result.
#!/bin/bash
extarray=( "3gp" "mp4" "mkv" "m4a" "webm" "mpg" "mpeg" "avi" "vob" "asf" "wmf" )
for ((n=0; n<${#extarray@}; n++))
do
if [ $n == "0" ]
then
optiname="-iname \".${extarray[$n]}\""
else
temp=$optiname
optiname="$temp -o -iname \".${extarray$n}\""
fi
done
echo "find . -type f \( $optiname \) | sort"
find . -type f \( "$optiname" \)
​
https://redd.it/1760ifx
@r_bash
Reddit
Explore this post and more from the bash community
Struggles of a noscripting noob
I decided to use a Windows subsystem for Linux, install Debian and play around with bash noscripting.
I have to say it has been somewhat frustrating. As a first attempt at something somewhat useful I decided to make a command function to start a new noscript.
I learned that functions don't even need a type declaration. you don't need to put the word function in the code for it to become a function.
I learned there is no one proper syntax for an if structure. There are multiple acceptable sysntaxes, but sometimes a space or lack of a space in the wrong place is fatal, while whether you use parens or square brackets might not matter.
Here is what I ended up sticking in the end of my .bashrc file:
function mbs { # command to make a new noscript
FILE=$1
echo $FILE
if [ $# -gt 0 \]
then
echo "%! /bin/bash" > $FILE
chmod u+x $FILE
echo "# $FILE" >> $FILE
nano $FILE
​
else echo "You need to supply a filename."
​
fi
}
The first improvement IMO would be to make sure it does not overwrite an existing file, but at least this is doing what I asked it to.
The reason for this post is just to express some surprise that the syntax of this language is important in some ways and not important in others. :D
https://redd.it/1769ezz
@r_bash
I decided to use a Windows subsystem for Linux, install Debian and play around with bash noscripting.
I have to say it has been somewhat frustrating. As a first attempt at something somewhat useful I decided to make a command function to start a new noscript.
I learned that functions don't even need a type declaration. you don't need to put the word function in the code for it to become a function.
I learned there is no one proper syntax for an if structure. There are multiple acceptable sysntaxes, but sometimes a space or lack of a space in the wrong place is fatal, while whether you use parens or square brackets might not matter.
Here is what I ended up sticking in the end of my .bashrc file:
function mbs { # command to make a new noscript
FILE=$1
echo $FILE
if [ $# -gt 0 \]
then
echo "%! /bin/bash" > $FILE
chmod u+x $FILE
echo "# $FILE" >> $FILE
nano $FILE
​
else echo "You need to supply a filename."
​
fi
}
The first improvement IMO would be to make sure it does not overwrite an existing file, but at least this is doing what I asked it to.
The reason for this post is just to express some surprise that the syntax of this language is important in some ways and not important in others. :D
https://redd.it/1769ezz
@r_bash
Reddit
Explore this post and more from the bash community
Looking for a Linux & Unix Discord Community?
Are you passionate about Linux and Unix? 🐧
Do you want to connect with like-minded individuals, from beginners to experts? 🧠
Then you've found your new home. We're all about fostering meaningful connections and knowledge sharing.
🤔 Why We Exist: At the heart of our community is a shared love for Linux and Unix. We're here to connect with fellow enthusiasts, regardless of where you are on your journey, and create a space where our shared passion thrives.
🤨 How We Do It: We foster a welcoming environment where open conversations are the norm. Here, you can share your experiences, ask questions, and deepen your knowledge alongside others who are equally passionate.
🎯 What We Offer:
🔹 Engaging Discussions: Our discussions revolve around Linux and Unix, creating a hub of knowledge-sharing and collaboration. Share your experiences, ask questions, and learn from each other.
🔹 Supportive Environment: Whether you're a newcomer or a seasoned pro, you'll find your place here. We're all about helping each other grow. Our goal is to create a friendly and supportive space where everyone, regardless of their level of expertise, feels at home.
🔹 Innovative Tools: Explore our bots, including "dlinux," which lets you create containers and run commands without leaving Discord—a game-changer for Linux enthusiasts.
🔹 Distro-Specific Support: Our community is equipped with dedicated support channels for popular Linux distributions, including but not limited to:
Arch Linux
CentOS
Debian
Fedora
Red Hat
Ubuntu
...and many more!
Why Choose Us? 🌐
Our server aligns perfectly with Discord's guidelines and Terms of Service, ensuring a safe and enjoyable experience for all members. 🧐 📜 ✔️
Don't take our word for it—come check it out yourself! 👀
Join our growing community of Linux and Unix enthusiasts today let's explore, learn, and share our love for Linux and Unix together. 🐧❤️
See you on the server! 🚀
https://discord.gg/unixverse
https://redd.it/176aqrh
@r_bash
Are you passionate about Linux and Unix? 🐧
Do you want to connect with like-minded individuals, from beginners to experts? 🧠
Then you've found your new home. We're all about fostering meaningful connections and knowledge sharing.
🤔 Why We Exist: At the heart of our community is a shared love for Linux and Unix. We're here to connect with fellow enthusiasts, regardless of where you are on your journey, and create a space where our shared passion thrives.
🤨 How We Do It: We foster a welcoming environment where open conversations are the norm. Here, you can share your experiences, ask questions, and deepen your knowledge alongside others who are equally passionate.
🎯 What We Offer:
🔹 Engaging Discussions: Our discussions revolve around Linux and Unix, creating a hub of knowledge-sharing and collaboration. Share your experiences, ask questions, and learn from each other.
🔹 Supportive Environment: Whether you're a newcomer or a seasoned pro, you'll find your place here. We're all about helping each other grow. Our goal is to create a friendly and supportive space where everyone, regardless of their level of expertise, feels at home.
🔹 Innovative Tools: Explore our bots, including "dlinux," which lets you create containers and run commands without leaving Discord—a game-changer for Linux enthusiasts.
🔹 Distro-Specific Support: Our community is equipped with dedicated support channels for popular Linux distributions, including but not limited to:
Arch Linux
CentOS
Debian
Fedora
Red Hat
Ubuntu
...and many more!
Why Choose Us? 🌐
Our server aligns perfectly with Discord's guidelines and Terms of Service, ensuring a safe and enjoyable experience for all members. 🧐 📜 ✔️
Don't take our word for it—come check it out yourself! 👀
Join our growing community of Linux and Unix enthusiasts today let's explore, learn, and share our love for Linux and Unix together. 🐧❤️
See you on the server! 🚀
https://discord.gg/unixverse
https://redd.it/176aqrh
@r_bash
Help with creating a bash code to compare two different files
Hello, everyone!
I'm currently encountering some challenges while working on a bash noscript in the Linux terminal to perform the following tasks:
1. Compare the values in the third column of two different files line by line.
2. If the values are different, save in a third output file the identifier from the second column of the input files, along with the corresponding values from both File 1 and File 2, similar to the "desired first output" example provided.
3. Additionally, create a fourth output file to tally the occurrences of each unique qualitative difference, taking into account the order (for example: 9690 0 ≠ 0 9690) while disregarding the identifier. This is illustrated in the "desired last output" example.
Any assistance or guidance in achieving this is greatly appreciated!
FILE 1
FILE2
DESIRED FIRST OUTPUT
DISIRED LAST OUTPUT
https://redd.it/176pcqr
@r_bash
Hello, everyone!
I'm currently encountering some challenges while working on a bash noscript in the Linux terminal to perform the following tasks:
1. Compare the values in the third column of two different files line by line.
2. If the values are different, save in a third output file the identifier from the second column of the input files, along with the corresponding values from both File 1 and File 2, similar to the "desired first output" example provided.
3. Additionally, create a fourth output file to tally the occurrences of each unique qualitative difference, taking into account the order (for example: 9690 0 ≠ 0 9690) while disregarding the identifier. This is illustrated in the "desired last output" example.
Any assistance or guidance in achieving this is greatly appreciated!
FILE 1
U E100033877L1C016R01601996031 0 140 0:106U E100033877L1C023R03303214633 0 140 0:106C E100033877L1C022R01901579971 27996 140 27996:1 0:7 27996:23 0:75C E100033877L1C023R02603225407 27996 140 0:32 27996:23 0:7 27996:1 0:3 27996:4 0:36C E100033877L1C020R02602000209 0 140 0:106C E100033877L1C023R03303214633 27996 140 27996:3 0:4 27996:5 0:94C E100033877L1C023R03101740491 9690 140 9690:13 0:8 9690:7 0:13 9690:9 0:56C E100033877L1C006R00200498634 9690 140 9690:71 0:35C E100033877L1C009R03603066069 27996 140 0:50 27996:2 0:1 27996:10 0:6 27996:11 0:26C E100033877L1C005R03300436825 27996 140 27996:3 0:6 27996:3 0:3 27996:5 0:86FILE2
U E100033877L1C016R01601996031 0 140 0:106U E100033877L1C023R03303214633 0 140 0:106C E100033877L1C022R01901579971 27996 140 27996:1 0:7 27996:23 0:75C E100033877L1C023R02603225407 27996 140 0:32 27996:23 0:7 27996:1 0:3 27996:4 0:36C E100033877L1C020R02602000209 27996 140 0:19 27996:4 0:3 27996:1 0:7 27996:23 0:49C E100033877L1C023R03303214633 27996 140 27996:3 0:4 27996:5 0:94U E100033877L1C023R03101740491 0 140 0:106U E100033877L1C006R00200498634 0 140 4840:106C E100033877L1C009R03603066069 4840 140 0:50 27996:2 0:1 27996:10 0:6 27996:11 0:26C E100033877L1C005R03300436825 27996 140 27996:3 0:6 27996:3 0:3 27996:5 0:86DESIRED FIRST OUTPUT
E100033877L1C020R02602000209 0 27996E100033877L1C023R03101740491 9690 0 E100033877L1C006R00200498634 9690 0 E100033877L1C009R03603066069 27996 4840DISIRED LAST OUTPUT
2 9690 0 1 0 279961 27996 4840https://redd.it/176pcqr
@r_bash
Reddit
Explore this post and more from the bash community
Best way setting arguments to noscript that is not able to read from the environment
Hello. I am working with a noscript that is not able to read variables from the environment and that I am not able to modify.
printenv
# a=123 b=234 c=345
# Script expects the variable content in arguments
./noscript para=123 parb=234 parc=345
What is the best way to handle a situation like this?
https://redd.it/176utr4
@r_bash
Hello. I am working with a noscript that is not able to read variables from the environment and that I am not able to modify.
printenv
# a=123 b=234 c=345
# Script expects the variable content in arguments
./noscript para=123 parb=234 parc=345
What is the best way to handle a situation like this?
https://redd.it/176utr4
@r_bash
Reddit
Explore this post and more from the bash community
Help... I got confused by the bash statement(while, if...)
Hello everyone, I have used bash since last year and was amazed by its powerful features, but I only treated it as a prompt that makes doing things faster then......
Until this month I started to learn bash noscripting and started to get confused by some of its logic... for example the noscript below, I still did not get it...
https://preview.redd.it/pv61mddgpytb1.png?width=947&format=png&auto=webp&s=6e807609771071c9d52af5178f0262d6a7a8d113
(1) If originally the battery was greater than 30, when battery was becoming lower than 30 , it did not quit the loop and did not showing the message either.
(2) If it was lower than 30 when I ran this program, it will show up the warning message and quit the loop.
​
I've searched for some information on the internet saying that "if [ \]" and "if " different, but I'm still not clear about the concept...
I will be appreciate if someone can explain it to me...thanks
https://redd.it/176xs3b
@r_bash
Hello everyone, I have used bash since last year and was amazed by its powerful features, but I only treated it as a prompt that makes doing things faster then......
Until this month I started to learn bash noscripting and started to get confused by some of its logic... for example the noscript below, I still did not get it...
https://preview.redd.it/pv61mddgpytb1.png?width=947&format=png&auto=webp&s=6e807609771071c9d52af5178f0262d6a7a8d113
(1) If originally the battery was greater than 30, when battery was becoming lower than 30 , it did not quit the loop and did not showing the message either.
(2) If it was lower than 30 when I ran this program, it will show up the warning message and quit the loop.
​
I've searched for some information on the internet saying that "if [ \]" and "if " different, but I'm still not clear about the concept...
I will be appreciate if someone can explain it to me...thanks
https://redd.it/176xs3b
@r_bash
Cant create a nested shells in bash beyond the Child shell using coproc command and process list
Suppose I run this command:
PID TTY STAT TIME COMMAND
40305 pts/0 Ss 0:00 bash
46922 pts/0 S 0:00 _ bash
46923 pts/0 S 0:00 | _ sleep 10
46924 pts/0 R+ 0:00 _ ps T --forest
Ok no problem, its exactly what I expected. But then, when i run the command like this:
PID TTY STAT TIME COMMAND
40305 pts/0 Ss 0:00 bash
47064 pts/0 S 0:00 _ bash
47065 pts/0 S 0:00 | _ sleep 10
47066 pts/0 R+ 0:00 _ ps T --forest
Note that, here,
So, what I was expecting was a process tree like this:
bash
_ bash
| _bash
| _ sleep 10
_ps T --forest
https://redd.it/177sgyg
@r_bash
Suppose I run this command:
coproc nested { sleep 10; } it executes sleep command within a childshell as expected. The process tree look like this when I run ps T --forest command.PID TTY STAT TIME COMMAND
40305 pts/0 Ss 0:00 bash
46922 pts/0 S 0:00 _ bash
46923 pts/0 S 0:00 | _ sleep 10
46924 pts/0 R+ 0:00 _ ps T --forest
Ok no problem, its exactly what I expected. But then, when i run the command like this:
coproc nested { (sleep 10); }, the process tree looks the same when I run ps T --forest command.PID TTY STAT TIME COMMAND
40305 pts/0 Ss 0:00 bash
47064 pts/0 S 0:00 _ bash
47065 pts/0 S 0:00 | _ sleep 10
47066 pts/0 R+ 0:00 _ ps T --forest
Note that, here,
(sleep 10) is a process list and it automatically should create a subshell to run the command sleep 10.So, what I was expecting was a process tree like this:
bash
_ bash
| _bash
| _ sleep 10
_ps T --forest
https://redd.it/177sgyg
@r_bash
Reddit
Explore this post and more from the bash community
setting a variable inside of a variable for loop
I pretty much have
x=0
myvar=$(for f in blah blah blah
do
printf stuff
x=$((x+1))
done
)
x is still equal to 0 at the end
If this is impossible then I need another way to count interations of this for loop
https://redd.it/1784yqa
@r_bash
I pretty much have
x=0
myvar=$(for f in blah blah blah
do
printf stuff
x=$((x+1))
done
)
x is still equal to 0 at the end
If this is impossible then I need another way to count interations of this for loop
https://redd.it/1784yqa
@r_bash
Reddit
Explore this post and more from the bash community
Input two characters and proceed
>VALUE=`zenity --entry --text="1-60"`
I have to enter two characters and then press enter. Is there an easy way to automatically complete the dialog after entering two characters?
https://redd.it/178ga2j
@r_bash
>VALUE=`zenity --entry --text="1-60"`
I have to enter two characters and then press enter. Is there an easy way to automatically complete the dialog after entering two characters?
https://redd.it/178ga2j
@r_bash
Reddit
Explore this post and more from the bash community
TMUX plugin for MacOS for playing Spotify playlists🌱
https://github.com/danjeltahko/spotify-tmux
https://redd.it/178jplg
@r_bash
https://github.com/danjeltahko/spotify-tmux
https://redd.it/178jplg
@r_bash
GitHub
GitHub - danjeltahko/spotify-tmux: Spotify plugin for tmux to add & start playing your favorite playlists & albums.
Spotify plugin for tmux to add & start playing your favorite playlists & albums. - GitHub - danjeltahko/spotify-tmux: Spotify plugin for tmux to add & start playing your fav...
function using unupdated information
this noscript is very long so I'll show the main idea
I orginally have a "$file" in "$mydir"
Then my noscript does this
function1 () {
for f in "$mydir"/*
do
printf "$f"
done
}
function2 () {
mv "$file" /tmp
function1
}
But when function1 is called, "$f" is still being printed even though it is no longer there.
I am using set -x to debug. The noscript works as expected. The file is moved to /tmp and no longer in "$mydir". I am also monitoring the directory using "ls" in realtime and again, it works as expected. When function 2 is called myfile is already gone from the directory so it should not be appearing there. But it is.
https://redd.it/178klt5
@r_bash
this noscript is very long so I'll show the main idea
I orginally have a "$file" in "$mydir"
Then my noscript does this
function1 () {
for f in "$mydir"/*
do
printf "$f"
done
}
function2 () {
mv "$file" /tmp
function1
}
But when function1 is called, "$f" is still being printed even though it is no longer there.
I am using set -x to debug. The noscript works as expected. The file is moved to /tmp and no longer in "$mydir". I am also monitoring the directory using "ls" in realtime and again, it works as expected. When function 2 is called myfile is already gone from the directory so it should not be appearing there. But it is.
https://redd.it/178klt5
@r_bash
Reddit
Explore this post and more from the bash community
Every 4 minutes, backup to git and if there are changes, increment commit version number and post to twitter.
crontab -e
> */4 * * * * /var/www/html/./updater.sh
updater.sh
#!/bin/bash
subsubversion=$(cat /var/www/html/.subsubversion);
cd /var/www/html;
git add *
git commit -m "v1.2.$subsubversion"
if ! [ "$(git push 2>&1)" = "Everything up-to-date" ]; then
((subsubversion++))
echo $subsubversion > /var/www/html/.subsubversion
./tweet.sh $subsubversion
fi
.subsubversion
> 0
tweet.sh
#!/bin/bash
source .twitterkeys
urlencode () {
[ -n "$1" ] \
&& echo -n "$1" | perl -p -e 's/([^A-Za-z0-9-._~])/sprintf("%%%02X", ord($1))/seg'
}
signature_method='HMAC-SHA1'
timestamp=$(date +%s)
nonce=$(md5sum <<< "$RANDOM-$(date +%s.%N)" | cut -d' ' -f 1)
url="https://api.twitter.com/2/tweets"
encodedURL=$(urlencode $url)
PARAM=$(urlencode "oauth_consumer_key=$consumer_key&oauth_nonce=$nonce&oauth_signature_method=$signature_method&oauth_timestamp=$timestamp&oauth_token=$token&oauth_version=1.0")
signature=$(echo -n 'POST&'$encodedURL'&'$PARAM|openssl dgst -sha1 -binary -hmac "$consumer_secret&$token_secret" |base64)
encoded_signature=$(urlencode $signature)
data="lockedon.life\nv.1.2."$1" is live!"
echo $data
curl -v -X POST \
$url \
-H "Authorization: OAuth oauth_consumer_key=\"$consumer_key\",oauth_token=\"$token\",oauth_signature_method=\"$signature_method\",oauth_timestamp=\"$timestamp\",oauth_nonce=\"$nonce\",oauth_version=\"1.0\",oauth_signature=\"$encoded_signature\"" \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{ "text" : "'"$data"'" } '
.twitterkeys
consumer_key="oSCP6sG3cxxxxxxxxxxxxxxxx"
consumer_secret="IPLhdABBjmJkoB0Swl9QxaJQ6fUQAqZqe2xxxxxxxxxxxxxxx"
token="1467985006530162690-qQG1dKMIZab504xxxxxxxxxxxxxxxx"
token_secret="40QZ6wql6TzCuXdMmvd9e1tubXjXsxxxxxxxxxxxxxxxx"
https://redd.it/178w823
@r_bash
crontab -e
> */4 * * * * /var/www/html/./updater.sh
updater.sh
#!/bin/bash
subsubversion=$(cat /var/www/html/.subsubversion);
cd /var/www/html;
git add *
git commit -m "v1.2.$subsubversion"
if ! [ "$(git push 2>&1)" = "Everything up-to-date" ]; then
((subsubversion++))
echo $subsubversion > /var/www/html/.subsubversion
./tweet.sh $subsubversion
fi
.subsubversion
> 0
tweet.sh
#!/bin/bash
source .twitterkeys
urlencode () {
[ -n "$1" ] \
&& echo -n "$1" | perl -p -e 's/([^A-Za-z0-9-._~])/sprintf("%%%02X", ord($1))/seg'
}
signature_method='HMAC-SHA1'
timestamp=$(date +%s)
nonce=$(md5sum <<< "$RANDOM-$(date +%s.%N)" | cut -d' ' -f 1)
url="https://api.twitter.com/2/tweets"
encodedURL=$(urlencode $url)
PARAM=$(urlencode "oauth_consumer_key=$consumer_key&oauth_nonce=$nonce&oauth_signature_method=$signature_method&oauth_timestamp=$timestamp&oauth_token=$token&oauth_version=1.0")
signature=$(echo -n 'POST&'$encodedURL'&'$PARAM|openssl dgst -sha1 -binary -hmac "$consumer_secret&$token_secret" |base64)
encoded_signature=$(urlencode $signature)
data="lockedon.life\nv.1.2."$1" is live!"
echo $data
curl -v -X POST \
$url \
-H "Authorization: OAuth oauth_consumer_key=\"$consumer_key\",oauth_token=\"$token\",oauth_signature_method=\"$signature_method\",oauth_timestamp=\"$timestamp\",oauth_nonce=\"$nonce\",oauth_version=\"1.0\",oauth_signature=\"$encoded_signature\"" \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{ "text" : "'"$data"'" } '
.twitterkeys
consumer_key="oSCP6sG3cxxxxxxxxxxxxxxxx"
consumer_secret="IPLhdABBjmJkoB0Swl9QxaJQ6fUQAqZqe2xxxxxxxxxxxxxxx"
token="1467985006530162690-qQG1dKMIZab504xxxxxxxxxxxxxxxx"
token_secret="40QZ6wql6TzCuXdMmvd9e1tubXjXsxxxxxxxxxxxxxxxx"
https://redd.it/178w823
@r_bash
Reddit
Explore this post and more from the bash community
Help needed with noscript
Hi all,
I have the following noscript that will not execute.
I think the space in the TARGET string is causing an issue but if I echo the last line I get
which is correct.
What am I doing wrong?
TIA
​
#!/bin/bash
# Purpose = Sync Google Photos
VENV="/home/gregeeh/gphotos/venv/bin"
TARGET='"/home/gregeeh/media/Google Photos"'
APP=$VENV/gphotos-sync
FLAGS="--album Hintons --skip-video --omit-album-date --port 11354"
$VENV/python $APP $TARGET $FLAGS
https://redd.it/178ylr5
@r_bash
Hi all,
I have the following noscript that will not execute.
Error is gphotos-sync: error: unrecognized arguments: Photos. I think the space in the TARGET string is causing an issue but if I echo the last line I get
/home/gregeeh/gphotos/venv/bin/python /home/gregeeh/gphotos/venv/bin/gphotos-sync "/home/gregeeh/media/Google Photos" --album Hintons --skip-video --omit-album-date --port 11354which is correct.
What am I doing wrong?
TIA
​
#!/bin/bash
# Purpose = Sync Google Photos
VENV="/home/gregeeh/gphotos/venv/bin"
TARGET='"/home/gregeeh/media/Google Photos"'
APP=$VENV/gphotos-sync
FLAGS="--album Hintons --skip-video --omit-album-date --port 11354"
$VENV/python $APP $TARGET $FLAGS
https://redd.it/178ylr5
@r_bash
Reddit
Explore this post and more from the bash community
CLI tool to check the World Cup 2023 matches schedule in your terminal.
Just created a node CLI for Cricket World Cup 2023!🏆 Now you can get match schedules right in your terminal. Just type 'npx wc23-cli' to explore!
Check out the CLI: https://github.com/MoazIrfan/wc-cli
Stay updated with match schedules. Happy cricketing!🎉 #Node #CLI
https://redd.it/1794stc
@r_bash
Just created a node CLI for Cricket World Cup 2023!🏆 Now you can get match schedules right in your terminal. Just type 'npx wc23-cli' to explore!
Check out the CLI: https://github.com/MoazIrfan/wc-cli
Stay updated with match schedules. Happy cricketing!🎉 #Node #CLI
https://redd.it/1794stc
@r_bash
GitHub
GitHub - MoazIrfan/wc-cli: CLI to check the Cricket World Cup 2023 matches schedule in your terminal.
CLI to check the Cricket World Cup 2023 matches schedule in your terminal. - GitHub - MoazIrfan/wc-cli: CLI to check the Cricket World Cup 2023 matches schedule in your terminal.