shell

  1. C

    Country and External IP Bash script

    I created a script based on what I could find on the INTERNET and some bash tutorials, that will show me my external IP and the country it's located in. # Script looks like this: #!/bin/bash wanip=$(dig +short myip.opendns.com @resolver1.opendns.com); echo "$wanip" > /root/Documents/filewanip...
  2. J

    Select a jar file in maven project

    I have a jar file in my target directory of Jenkins Maven project. PROJ-0.0.2-SNAPSHOT.jar. There is another file called, PROJ-0.0.2-SNAPSHOT.jar.original I want to select only PROJ-0.0.2-SNAPSHOT.jar file. For that I used below command. ls target | grep \.jar$ I got the output as my...
  3. E

    Am I using the correct syntax for my shell script? [duplicate]

    I wrote a shell script that gets a value from a file and based on that value I want to echo a particular message. My console keeps on saying that there is an error on line 7 and 9. Any suggestions on how to fix it will be greatly appreciated. export...
  4. J

    Pass variable as options to curl in shell script linux [duplicate]

    I'm trying to update some info of a web site using curl through a script but it's not working well, this is the code i have: CURL_STD_OPTS="-k --header 'Content-Type: application/json' --header 'Accept: application/json' curl "$CURL_STD_OPTS" -X POST --data '{ "actual": '"$BAL"' }'...
  5. D

    Bash function doesn't work for remote ssh command execution although interactive shell function fine

    I define a function in .bash_aliases file and include it in my .bashrc file. My .bash_aliases file: function dmidecode() { if [[ $1 == -t && $2 == 1 ]]; then cat ~/some_file else command dmidecode "$@" fi } The function is: when someone...
  6. J

    Pipe echo of change the current directory to sh does not work

    If I do the code: echo "printf 'working'" | sh the code prints out working but when I want to change the current directory this way: echo "cd ../" | sh the current directory isn't changed. Do you know the reason behind that behavior? do you know how to echo cd command to sh in a working way?
  7. S

    As part of shell script, sudo su is not working. Any alternate?

    The below 3 lines are part of my shell script, but it is executing first line and copying file properly. In-order execute this rpm file, i need to prompt to root user. Hence, 2nd step i wrote. But it is not executing, hence i'm not able to install the rpm file. aws s3 cp...
  8. L

    Prevent race condition when creating lock file

    My script must not be run more than once concurrently. So it creates a lock file, and deletes it before exiting. It checks that lock file doesn't exist before starting its work. A very common approach to locking is something like this: function setupLockFile() { if (set -o noclobber; echo...
  9. D

    Print all lines in a file not beginning with hash and also filter by a specific column

    I've got a tab separated file with header lines beginning with #. I want to trim all the header lines and also the lines where column #2 does not begin with 0/0. I've got the first logic (removing the header lines) right but when I add the second logic (which I'm not sure if it is the right way...
Top