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
1 answer

ZFS Send Script works when run manually but not in Cron (Already tried common solutions)

Script on sending end is as follows: #!/bin/sh #Variables bigdata=vid-zfs-live/bigdata today=`gdate +%m-%d-%y` yesterday=`gdate -d'yesterday' +%m-%d-%y` #Actions zfs snapshot -r "$bigdata"@"$today" zfs send -i "$bigdata"@"$yesterday"…
Copy Run Start
  • 734
  • 1
  • 9
  • 27
1
vote
1 answer

Bash: How do I pass "command not found" text into my trap function?

I have the following: test.sh . Foo.sh Foo.bar Foo.baz Foo.blah and Foo.sh function Foo.bar() { echo 'I am a bar!' } function Foo.baz() { echo 'But, I am a baz!' } function Foo.error() { # I should suppress the 'command not found'…
Housni
  • 111
  • 1
  • 6
1
vote
0 answers

Simple way of restarting crashed processes in server within 3 attempts if its exceed need to skip the script?

I have one file name hello.sh. I'm running that file at every 30 mins from crontab. In hello.sh, I have script for checking the service whether it is running or not. if its not running then it will send a mail and restart the service. hello.sh…
user313017
  • 11
  • 1
1
vote
1 answer

subshell is not created if run commands without a path?

I'm reading the book "Linux Command Line and Shell Scripting Bible" 3rd edition. On page 279, here I quote: "Command substitution creates what's called a subshell to run the enclosed command. A subshell is a separate child shell generated from …
user312130
  • 11
  • 2
1
vote
2 answers

Get a file's ctime, atime, mtime and extended attributes

I would like to display a file's ctime, mtime and atime along with whether it has extended attributes or not. There are 2 commands that can do this but I have not been able to combine them into a single command to give a single line of output. find…
KennyC
  • 113
  • 3
1
vote
1 answer

Get OpenVPN client IP script

My machine get's an IP from OpenVPN server when connecting to the VPN gateway. This is tun0 on Ubuntu. I assume naming might be different for other systems that may connect to OpenVPN gateway. Is that a reliable way (a script) to determine an IP,…
Maxim V. Pavlov
  • 663
  • 3
  • 11
  • 29
1
vote
1 answer

Trying to get pid from a script running as su -c

I am trying to get these scripts to work in an environment where the java application needs to run as user foobar no matter if it is started as root or foobar. So these are my modifications to the init script, which is symlinked from…
1
vote
2 answers

#!/usr/bin/expect not working

This is probably an easy question, however have a simple expect script that I've add the executable bit to that seems to be ignoring the #!/usr/bin/expect interpreter line. Further more, it also seems like variables are not being set since when I…
Jim
  • 988
  • 7
  • 20
  • 33
1
vote
2 answers

Special char or wildcard in awk field separator

Would appreciate to know about the special char or wildcard in the following command: /sbin/ifconfig eth0 | awk -F ' *|:' '/inet addr/{print $4}' What does the code below mean? awk -F ' *|:' '
krock1516
  • 128
  • 1
  • 5
1
vote
1 answer

Bash Script to set Linux OS

I'm working on a bash script and ran into an issue. I'm pushing what I know from using normal if/fi statements and trying to use them to set variables related to picking up the OS version, such as RH 7, Debian 7, Ubuntu, etc. The problem I'm having…
five0va
  • 31
  • 2
1
vote
1 answer

Export or Forward /var/spool/mail/USER (readable for customer)

there are some bounce mails in the /var/spool/mail/USER directory that failed to send. Now the customer receives all of those mails from us because he does not have direct access to them. I can forward one by one with mutt, but there are so many of…
LeMike
  • 179
  • 1
  • 8
1
vote
1 answer

Bash: Output of a command is written only to screen and not to another file while using tee, what could be the reason?

In order to troubleshoot some ftp connection error, I've been instructed to write a bash script which will infinitely connect to a remote frp server and get one file from there. ftpuser="ftpuser" ftppasswd="ftppasswd" ftpsrv="download.akamai.com"…
Itai Ganot
  • 10,644
  • 29
  • 93
  • 146
1
vote
0 answers

Linux: What could be the reason for random fails in updating passwd.byuid by running yppasswd?

In order to allow NOC users in my company to manage users through NIS I've created the following script: #!/bin/bash # This script will simplicate NIS user management. # You will not be able to change password or delete users peeradmin and root…
Itai Ganot
  • 10,644
  • 29
  • 93
  • 146
1
vote
1 answer

SSH issues: keyfile and host file not working as expected

When I login to server with a key ssh -i /home/me/.ssh/id_rsa server everything goes without glitch. The key is authorized on the server. However if I try to do same from a shell script, I get a password request. Same happens when I try to scp…
Peregrino69
  • 149
  • 6
1
vote
2 answers

Executing local function code on a remote server

I am updating about 20 bash scripts that perform various server-side operational tasks, checking status / sending reports etc. On some environments these scripts will run locally, on others they need to run remotely. The scripts should detect…
dwurf
  • 920
  • 8
  • 15