Questions tagged [shell-scripting]

Programming in an Interpreted language executed by a running Shell

Generic programming in an Interpreted language (as opposed to compiled) executed by a running Shell. Sometimes referred to as "Glue Code" due to the practice of managing the execution and output of one or more compiled binaries and passing said output to another series of commands.

621 questions
1
vote
2 answers

Trying to make Script

first of all I need to say that I'm not a programmer, but I need to do something based on programming.... My problem is that I need to modify the DNS servers in almost 1000 nanostation equipments. I have access to them through ssh and I want to make…
gasparmenendez
  • 63
  • 1
  • 2
  • 6
1
vote
1 answer

Can't send password to scp prompt during boot

I have Ubuntu OS with encrypted partition. During boot, I want to download keyfile from remote server using scp and use it to decrypt partition. What I did: /etc/initramfs-tools/hooks/myhook.sh #PREREQS blah blah mkdir ${DESTDIR}/usr mkdir…
akasummer
  • 111
  • 2
1
vote
1 answer

Linux Free Disk Space per Device

In my system, df -hT outputs something like this: > df -hT Sist. Arq. Tipo Tam. Usado Disp. Uso% Montado em devtmpfs devtmpfs 1,9G 8,0K 1,9G 1% /dev tmpfs tmpfs 1,9G 616K 1,9G 1% /dev/shm tmpfs tmpfs …
1
vote
1 answer

Delete all folder not containing filename matching glob/regex

I want to do the following. I have depth 2 file hierarchy like this: A | B | | g | | h50000 | C Where A, B, C are folders. I want to delete all folders without files matching specific patters, (in my case 50000 is pattern, glob style) on depth…
nmiculinic
  • 113
  • 4
1
vote
1 answer

Select remote database from bash

I'm kind of new in bash/shell scripting and I'm trying to remotely select from mysql database and check if record exist or no. Based on respond will do some stuff. This is what I have as a command mysql -u mysql -pMysql123 -h xxx.xxx.xxx.xxx…
VLS
  • 125
  • 1
  • 4
1
vote
4 answers

Grep by block of text\lines

I have the text, that contains some lines. So, i need to make GREP of several lines. For example, i have repeating text and i should GREP get lines, that have this repeating key-words. grep -o "test|test2" textfile My text: 123|never for…
Valeriu
  • 57
  • 2
  • 9
1
vote
2 answers

Script to delete FTP data older than 7 days

Currently I am using following simple line script to take backup of server directory to remote FTP location # Take backup to remote location ncftpput -z -R -uusername -ppassword ftp.example.org /destination/directory /source/directory Now, I just…
Farmi
  • 379
  • 1
  • 4
  • 17
1
vote
1 answer

How to replace an entire NGINX block with sed?

I am starting to learn bash script and need to write a script to install fastcgi_cache on NGINX. I need to replace the default location for PHP with the one with the fastcgi_cache settings. To be clear, I need to replace this: location ~ \.php$ { …
1
vote
1 answer

Bash script, read from file and write to other file

i have proxy server called 3proxy. I need to add ip like this: flush auth iponly strong deny * * * 25,2525 * * * allow test proxy -n -a -i192.168.110.1 -e192.168.110.1 -p65233 socks -n -a -i192.168.110.1 -e192.168.110.1 -p65234 This is a…
1
vote
1 answer

Bash, script that check soft

i have a script on bash: s=0 if [ -f /usr/bin/curl ] && [ -x /usr/bin/curl ] ; then echo "Utility ...... curl [ ok ]" else echo "Utility ...... curl [fail]" s=1 fi if [ -f "/bin/grep" ] && [ -x "/bin/grep" ] ; then echo …
Valeriu
  • 43
  • 1
  • 2
  • 8
1
vote
2 answers

Bash scripting error checking using word count and awk

Need a light on my script I am doing a word count on a variable get a 0 or bigger value but it seems the script is breaking at on this variable function count_check=wc -l $TABLE_CHECKS | awk '{print $1}' or the if [ $count_check -eq 0 ] please…
Haohmaru
  • 113
  • 4
1
vote
1 answer

Can't get PID from backgrounded java job

The PID file for this statement is created but it is always empty. When running the shell with -x I see that $! empty, yet at the end the java job is left running in the background as desired. Why is the pid missing? su - $USER -c "nohup java…
Neil H Watson
  • 448
  • 1
  • 5
  • 18
1
vote
1 answer

How to write a shell script to search from a position in file instead to start from beginning of the file again

I am trying to write a shell script to find value stored after a repetitive word in a big file with millions of lines using for loop. After the finding the repetitive word how i make script to start searching after the present line in file so that…
1
vote
2 answers

Inotify & Rsync - Don't move files before download is completed

I am using a local website which downloads files to my server. Using an Inotify daemon I'm listening for file changes in a specific folder (the one I am downloading to) and executing a script which moves those files into another folder using rsync.…
PoTTii
  • 21
  • 1
  • 4
1
vote
0 answers

elinks | dump after form submit

i'm trying to find a way, to dump the content of a page, when form is submitted by elinks. /usr/bin/elinks -auto-submit 1 -eval 'set document.browse.forms.confirm_submit = 0' $LINK If -dump is used, will export the content of the page before…
axelkeegan
  • 11
  • 2