Bash scripting is making scripts in the Bash shell language.

learn more… | top users | synonyms

0
votes
1answer
23 views

How to pipe binary stdout to a compressed tls connection?

Not so long ago, I could use : cat somefile.txt | openssl s_client -connect server:port -quiet -comp However, this command doesn’t work, even with-ign_eof: $ cat somefile.bmp | openssl s_client ...
0
votes
1answer
6 views

lost virtualenv display to the left of bash prompt

I added thy Holy prompt to display my current branch so I never push to master. We all use it and it works, but I am no-longer seeing what virtualenv I'm using at the moment, which is a hassle. Based ...
0
votes
1answer
15 views

Run script without typing sh on Android

I wanna run my script which is located in system/bin and permissions is 755. With sh myscript there is no problem but myscipt or ./myscript doesn't work even if the pwd output is /system/bin. On ...
0
votes
2answers
29 views

Replace backslash(“\”) with forward slash(“/”) in a variable in bash

I want to replace backslash(\) with forward slash(/) in a variable in bash. I tried it like this, but it doesn't work: home_mf = ${home//(\)//(/)} For example, I would like \a\b\c -> /a/b/c
0
votes
0answers
15 views

Lua variable as a shell command

Hii aLL Im using Awesome Wm and i want to set a shell command as a variable on my rc.lua i look in Internet and i found this : SHell Command : $ ip link | grep "[1-9] :en" | cut -d ":" -f2 | awk ...
1
vote
0answers
20 views

How to find processes which uses the most RAM in last X seconds?

Could you please help me to sort this out? I'm trying to write a bash script which will monitor ram usage (not only ram but cpu and network as well) and show me 3 processes which use the most ram in ...
1
vote
1answer
21 views

Bash: Is it possible to declare each list item on a new line?

Example: You normally list values in a horizontal layout for var in 0 1 2 3 4 5 6 7 8 9 do echo $var done It would be nice for version control and readability purposes to enter each list item on ...
0
votes
2answers
34 views

Why the simplest Shell-Script isn't working?

I want hide the path in the Terminal and for that reason I typed: export PS1='> ' command which I found online with positive result. I thought to make it to a shell-script in order to not type ...
0
votes
2answers
16 views

running chained bash function commands in background

I am attempting to call port() { fuser -k $1/tcp; python manage.py runserver $1 ;} runproject() { cd $HOME/projects/$1 ; workon $1 ; port $2 & ; sleep 3 ; google-chrome 127.0.0.1:$2 ;} (port is ...
0
votes
2answers
22 views

Evaluate each environment variable and set it back in ubuntu

I'm trying to write a shell script which reads all the environment variables, evaluate them for included env. variable with in them and re-export after evaluvation. Example - I've an environment ...
0
votes
1answer
13 views

Is there a native alternative to the `watch` command; for Darwin/OS X

I have a script that I'm trying to port from Linux to Darwin/OS X. The Linux version currently depends on the watch command, which doesn't appear to be installed on Darwin/OS X by default. What's the ...
0
votes
1answer
40 views

Shutdown a linux computer depending on the battery level

Is there a way to shutdown a linux-based computer when the battery charge drops below a certain level? I have searched through the shutdown and poweroff manuals but found nothing relevant.
2
votes
1answer
30 views

How to avoid terminal to scroll down to last message in bash?

I write a bash script that run some other commands in new terminal: #!/bin/bash # Sample script gnome-terminal --title="blah blah" -x bash -c ffmpeg -i udp://239.1.2.1:60001?fifo_size=50000000 ...
0
votes
1answer
28 views

Dictionary attack in Bash with cURL

I'm fairly new to Bash, but this is a script I've been working on for the past few days. It's meant to run a dictionary attack on an HTTP-POST login for a website, by reading the time module and ...
1
vote
2answers
14 views

If Statement not evaluating as expected. Am I setting up my variables incorrectly?

I am trying to create a command that will allow me to check websites for specific words. I used \ at the end of the line to wrap it to the next, (not sure if I used those correctly here) these ...
0
votes
0answers
3 views

Is it possible to download the document from a typo3 CMS?

I have access to a typo3 CMS. The CMS displays documents in a viewer with tiled images at several zoom levels. The CMS also allows a download via a munged up PDF. By this I mean what is visible in ...
-2
votes
3answers
281 views

How can I write a bash function that checks if an integer is even or not?

How can I write a shell predicate function event that takes an integer argument and tests if it's even or not?
0
votes
1answer
39 views

Bash loop for adding --exclude list to tar

I have a bash script I made to encrypt/decrypt using GPG and tar. Right now I have my --exclude hard coded into the script, but I'd like to make it a bit more dynamic and add the items to exclude as ...
0
votes
0answers
18 views

calculate avg time for 3 person time in linux

how can i show 3 person's average sum in linux? For example, let the times for dough be 1,2,3,4,5 seconds delta be 5,6,7,8,9 amanada be 7,4,5,6,7 in bash script for all 3 users
0
votes
2answers
50 views

using sed in BASH script: replace text with info from system variables (hostname and date)

I want to use a bash script to run a backup and then send me an email using ssmtp. I am trying to make a generic script that I can reuse across different Linux machines. Below is a snippet of the ...
0
votes
1answer
16 views

Can I set a process name for my tomcats on CentOS ?

I have several tomcats running on my centos. If I try "top", all of them are shown as "java" . Is there anyway, such as changing the catalin.sh, that I can make each of the tomcat has its own name ...
0
votes
1answer
28 views

My bash script's if / then check is always evaluating to true

I was trying to write a bash script to handle a conditional switch, and it kept evaluating to true every time. So, I stripped it down to this, and I was getting the same behavior of it always echoing ...
1
vote
1answer
25 views

Bash: return all the characters between the nth occurence of two different strings within a string

In a bash script (on Ubuntu 14.04) I'm running the command: WP055="$(wget -qO - http://alerts.weather.gov/cap/wwaatmget.php?x=CAZ055&y=1)" Within the WP055 variable string there will be an ...
3
votes
1answer
34 views

Confused about jq parser

I'm trying to use jq parser in my bash scripts and I'm confused about how it works, could someone explain what am I doing wrong? Here is the original file from the external service and I need to get ...
1
vote
2answers
66 views

Running script that has sudo commands with sudoers

I wrote a script that helps clean up my downloads and anime, but it won't run without root. So I tried adding it to /etc/sudoers (edited using techraf's suggestions): # This file MUST be edited ...
0
votes
0answers
35 views

Need help on how to create a Youtube Automatic Artist Discography List Generator and use this bash script to play it

Example: #FrankSinatra <-- based on youtube automatic generator "Top Tracks", then passing that list to this bash script player (listed below) randomly or not, could also accept more artists, ...
1
vote
1answer
48 views

Who could streamline this script better than what it is?, regarding mostly those tmp's

#!/bin/sh -e # # Usage: # ytpl song title # ytpl < titles # go() { echo "Playing $1" # Force TTY input for controls even if titles are read from input echo https://youtu.be/ > ...
0
votes
0answers
9 views

Variable from dialog box input doesn't behave as expected

I have a variable which the user sets by selecting from a dialog list. The variable is later used to cd. The variables are subdirectories in the format "sub.domain.tld." Import options array m here ...
0
votes
1answer
20 views

Tar compress directories and contents into individual, dated files based on folder name bash script

This is on a Debian system. I have had the compression of files and contents into individual folders working fine but not with the date added to the file names. Removing the date part, it works as it ...
0
votes
0answers
17 views

TFTP error code returned in bash

I have the below code to check on tftp error in my bash script. # fetch images from tftp server tftp_fetch() { echo "Fetching via tftp: $1:$tftp_path/$2" if ! tftp -g $IPADDR -r ...
0
votes
1answer
17 views

write a variable to a file on the end of a specific line

I want to add a variable to the end of a specific line in file file.txt. My code so far: #!/bin/bash read -p "What is the path of the repo? > " input echo :$input >> file.txt I want ...
0
votes
1answer
38 views

Linux: How does file modification time affect directory modification time and directory access time?

I would like to learn more about how file access time and file modification time related to directory access and modification times. I did read the "questions allowed here" but if there is a better ...
0
votes
1answer
20 views

bash script error when running executing openvpn service

I am trying to develop a bash script that calls a service from within: #!/bin/bash interface=dev0 mycommand="sudo openvpn --config '/etc/openvpn/optionFile.ovpn'" $mycommand When I run the script ...
0
votes
0answers
14 views

Stop bash script with any key

I'm writing a script which I want to stop with any key I choose. After pressing the key, my intention is to complete all my commands at that moment and start su. I've tried adding a & to my ...
0
votes
1answer
25 views

Extract the first 2 letters in each line of a file using a single command Terminal

I want to extract the first 2 letters of each line from a file and save it in a variable and print it in a single command. Can anyone help me with the command? Considering my file has 20 - 30 lines ...
-1
votes
1answer
24 views

Script to Update time

I am using a old laptop which lacks a battery so the wake-up time is during 1980. Thus, I use the NTP service to update the time to the current time.Is there a script to achive this. My os is ...
1
vote
1answer
32 views

for loop (f in *.txt) throws error if no *.txt file exists

I have a small bash script which looks something like this: #!/bin/sh for f in ./*.txt do f=$(basename $f) echo "Processing $f" scp somewhere mv $f done/`basename $f` done This is working ...
3
votes
2answers
37 views

Bash scripting: 365-024=345?

I am trying to build some beginner scripts with bash. I want to find how many days left from today until the end of the year, using date program. So I am using a variable, current_date=$(date +%j) to ...
1
vote
3answers
31 views

Show which command failed

command1 && command2 && echo "OK" || echo "FAIL" This will print OK if both commands succeeded or FAIL if either of commands failed. How can I modify this to print: OK if both ...
0
votes
1answer
46 views

Behavior of same commands (under Bash) - running one by one in console vs as single script

Running on OS X 10.11.1, I execute the following series of commands (one by one), in the console: FILE="a b c.tiff" # file in the current folder VAR=$(mdls -name kMDItemContentCreationDate $FILE) # ...
0
votes
0answers
18 views

Add remmina rdp connection entry on many computers

i want to add remmina rdp connection entry on many computers (~200). I know that the remmina keeps every connection entry in single file in ~/.remmina, so i wanted to write script that will copy this ...
0
votes
0answers
46 views

Can the wmic command reliably be used in script batch files?

I believe that the following command: wmic product where "name like '%%winzip%%'" call Uninstall shuts down PC's when deployed with SCCM. Has anybody came across any issues with the command similar ...
-2
votes
2answers
69 views

Bash: if [ tar = error ] [closed]

I want a shell script to write a message depending on whether tar succeeds or fails, but this script doesn't work correctly: TAR=$(tar -cf Archiv.tar myfolder/ myotherfolder/) if [ ! "$TAR" = ...
3
votes
2answers
53 views

make file size at least 1MB

I'm trying to learn about operating systems by making one myself and testing it in virtual-box, but VBoxManage convertfromraw doesn't allow my source file to be very tiny (512B). Are there any bash ...
1
vote
1answer
170 views

How to mail output of shell script as a cron job

I've created a cron job that runs a shell script. I'd like the shell script to run and capture it's output and have it emailed upon completion. Here's what I have so far, but the mail message body ...
4
votes
1answer
52 views

Files with space in name

I have a variable called var that stores the list of files inside a directory. I loop through all the files and if I find a directory I output "Directory" to the screen. code below: var=$(ls dir) ...
0
votes
1answer
31 views

I want a for loop to go through files with two diffrent extensions

I want the following loop to go through m4a files AND webm files. At the moment I use two diffrent loops, the other one just replaces all the m4a from this loop. Also the files that ffmpeg outputs ...
1
vote
2answers
152 views

How to use Bash script to find .mov files recursively and convert them to .mp4 using ffmpeg

I'm working on a Mac system in a video company where I have to clean up a lot of folders and subfolders containing large intermediate video files. So I've been looking for a way to batch convert ...
0
votes
1answer
251 views

“line 3: syntax error near unexpected token” in a shell script

I am trying to run some executable with parameters several times. I wrote a script for it. But I am always getting an error and can't figure out on how to fix it. #!/bin/bash export ...
0
votes
1answer
37 views

bash script read line by line

Hello I am trying to create a script that reads my file take all the variable it needs then use it for another command. But it seems that the variables are not being memorized, because I tried a ...