Search Results

Search: Posts Made By: da1
9,337
Posted By da1
hmm, very interesting construct. thank you for...
hmm, very interesting construct. thank you for that.

One question though regarding the following piece of code:
[[ 0 = $ret ]] && \
exit_msg="SUCCESS - $exit_msg" || \
exit_msg="FAILURE -...
9,337
Posted By da1
no it's not homework. I've made some changes...
no it's not homework.

I've made some changes to it (whole code as requested):



# if we specify a proxy on $2, add the -x flag to curl
if [ "$proxy" ]; then
# the whitespace is important...
9,337
Posted By da1
Custom exit message according to flag
Hello everyone,

I'm currently working on a script that uses curl's to check internet connectivity with and without a proxy being specified.
Basically what I'd like to achieve is having the...
Forum: Programming 09-06-2019
10,367
Posted By da1
This is what I came up with so far, thank you for...
This is what I came up with so far, thank you for the hints:
workdir='/tmp'
iso_name='install65.iso'
sha_file='SHA256'

file = open(workdir + '/' + sha_file, 'r')
for lines in file:
...
Forum: Programming 08-20-2019
10,367
Posted By da1
[Python] replicating "sha256 -C checksum_file.txt file.txt"
Hello everyone,

Since my python knowledge is limimted, I've challenged myself to learn as much as possible to help me with my carrere. I'm currently trying to convert a shell script to python,...
530
Posted By da1
Thank you, I read up on "variable indirection"...
Thank you, I read up on "variable indirection" and it now makes sense.
530
Posted By da1
What does the "!" in "${!VARIABLE:-\n}" mean?
so I'm going over this script someone else wrote and I haven't seen the aforementioned construct before.


The code says:
declare VAR1="${!VARIABLE:-\n}"


I know what the ":-\n" does but I...
1,912
Posted By da1
I actually had it in quotes but copy pasted the...
I actually had it in quotes but copy pasted the initial code that I ended up adjusting.
1,912
Posted By da1
What I ended up doing was using a piece of code I...
What I ended up doing was using a piece of code I found on stackoverflow:
json2keyvalue() {
echo $JSON | jq -r '{Element1,Element2,Element3} | to_entries|map("\(.key)=\(.value|tostring)")[]'
}...
627
Posted By da1
I understand. Thank you!
I understand. Thank you!
1,912
Posted By da1
Different behavior between bash shell and bash script for cmd
So I'm trying to pass certain json elements as env vars and use them later on in a script.


Sample json:
JSON='{
"Element1": "file-123456",
"Element2": "Name, of, company written in,...
627
Posted By da1
damn, that's a good one, dankeschoen. ...
damn, that's a good one, dankeschoen.


BTW, regarding this:
# form the cmd to be executed BASE_CMD="base_cmd arg1" # if err=0, append "arg2" SUCC_CMD="$BASE_CMD arg2" # if err=1, change arg2 to...
627
Posted By da1
I was thinking about a case statement but I have...
I was thinking about a case statement but I have to evaluate $err and the value of $TAG together and I'm not sure how that would look and work. I guess something like this:

case "${err}" in
...
627
Posted By da1
Better solution for this "if" spaghetti
Hello everyone,

I'm stuck and I need some help with rewriting the following code. It's ugly af and I'm not sure which direction to go.



err=0
trap 'err=1' ERR


# these 2x env. vars will...
945
Posted By da1
yep, that was it. Thank you very much!
yep, that was it. Thank you very much!
945
Posted By da1
#!/bin/bash ...
#!/bin/bash

AMI_TAGS="env=prod,city=xxx,country=XXX"

AMI_TAGS="${AMI_TAGS//,/ Key#}"
AMI_TAGS="Key=${AMI_TAGS//=/,Value=}"
aws ec2 create-tags --resources ami-1234 --tags "${AMI_TAGS//#/=}"
...
945
Posted By da1
One question, would it be possible to get the...
One question, would it be possible to get the output without the single quotes?

currently getting: aws ec2 create-tags --resources ami-1234 --tags 'Key=env,Value=xxx Key=city,Value=xxx...
945
Posted By da1
damn, that worked. thank you very much. ...
damn, that worked.

thank you very much.

now if I may ask, I can come very close ti the same result with:sed -e 's/,/ Key#/g' -e 's/=/,Value=/g' -e 's/#/=/g' but the first value "env" in this...
945
Posted By da1
A better way to manipulate text
Good morning everyone,

I'm currently trying to convert an environment variable into a string and then attach it at the end of a command and launch it.

I have the following right now, but it's...
1,331
Posted By da1
PHP - add rm %dir to php code
Hello everyone,

I'm trying to modify a php file to perform 2 actions in an if statement.

// If the delete button is pressed
if(isset($_GET['delete']) &&...
4,253
Posted By da1
ksh - default value for getopts option's argument
Hello everyone,

I need help in understanding the default value for getopts option's argument in ksh. I've written a short test script:

#!/bin/ksh

usage(){
printf "Usage: -v and -m are...
1,502
Posted By da1
cmd || echo "something" - doesn't exit uppon error
Hi guys,

I have a shell script where I have the following:

for i in ad0 ad1
do
gpart create -s gpt $i || echo "Cannot create GPT partition on "$i". Exiting ..."
gpart add -s 128 -t...
810
Posted By da1
best practises for scripting + a few unclear points
Hi guys,

Besides the points bellow, what would best practices for scripting be ?

1) set the PATH
2) unset the current environment (set -u ?)
3) (re)set the IFS to default value - space...
1,395
Posted By da1
Wow .... thx, it works. Have to read what each...
Wow .... thx, it works. Have to read what each option does. RTFM time.

THX !! :)
1,395
Posted By da1
match and assign variables
Hi guys,

I'm currently writing a script for automating a FreeBSD ZFS setup (ZFSonRooT). I got stuck at one point for raidz(1,2 a.k.a raid5,6) and am in need of assistance.

This is what I need....
Showing results 1 to 25 of 25

 

Featured Tech Videos

All times are GMT -4. The time now is 09:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy