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
2
votes
0 answers

Error in killing Tshark from shell script

I'm getting this error: * glibc detected * /usr/sbin/tshark: double free or corruption While doing as below, any idea why? #!/bin/bash trap 'my_exit; exit' SIGINT SIGQUIT count=0 /usr/sbin/tshark -i bond1.1 -f "port 1111" -w /test/test_1.pcap >…
2
votes
3 answers

scp stuck when trying to copy files from Linux to windows

I use the following scp syntax in order to transfer allot of files from Linux red-hat 5 to windows machine ( under Temp directory ), Remarks: SSH server already installed on windows machine I use this line in my shell scripts sshpass -p…
Eytan
  • 611
  • 6
  • 13
  • 27
2
votes
1 answer

Hold till last command completes its execution

I am developing a shell script which actually stops aws running instances in a particular region & start them again as a part of schedule maintenance. but as ec2-api tools are heavy, takes time to execute the ec2 command. I want my system to hold up…
Shailesh Sutar
  • 1,517
  • 5
  • 23
  • 41
2
votes
3 answers

In zsh, how do you redirect stderr to /dev/null within a for or foreach loop?

I am trying to accomplish something that is easy in bash: look for files in a folder and source them if they exist (and do not output if no files exist). In bourne shells this is how to do it: if [ -d /etc/profile.d ]; then for f in `ls -1…
chrishiestand
  • 974
  • 12
  • 23
2
votes
1 answer

Bash: php comand not found when called from a script run with sudo

I have this weird problem. The php command is not found in one specific sitiation. I try to call the command in three different ways. Only one of them fails: Being user john I create a simple script which calls php --version. Then as user root I…
GetFree
  • 1,500
  • 7
  • 23
  • 37
2
votes
3 answers

how to run shell commands from apache (through php )

I'm using redhat 6 I have the following shell commands that I need to run from the webserver (apache -> through php ) that basically move & overwrite a file , kill a process and starts another . Obviously for some reasons all the operations are…
user1963938
  • 51
  • 2
  • 2
  • 6
2
votes
2 answers

Using NFS mount script with grandfather father-son script but only getting 6 daily backups. I should also have 4 weekly and 2 monthly backups

I'm using rsync to clone changes from a remote server(MT DV4.0) to a local one(ubuntu 11.10). I'm then using the following copy/paste script to compress then archive the files. #!/bin/bash #################################### # # Backup to NFS mount…
Bms85smb
  • 153
  • 1
  • 6
2
votes
1 answer

How to combine outputs of ps and lsof

Usually output of ps has a pid somewhere. Is there a way to combine this, preferably with a one-liner, with an output of lsof ? e.g. 27915 ? Ss 0:03 gpg-agent --daemon gpg-agent 27915 httpd mem REG 104,1 144776 …
Alex
  • 1,828
  • 4
  • 31
  • 52
2
votes
1 answer

Distributing a custom command line tool to enterprise servers

I've been tasked with building a command line tool that we will be providing to our enterprise customers so that they can use the API to upload data to our platform. The API works with standard cURL requests, so I can do most of the basic…
2
votes
2 answers

CentOS 6.2 cron.daily

I created a new file "dbbackup" in /etc/cron.daily that contains a simple database backup script. #!/bin/sh mysqldump -h localhost -u user -p'passord' database_name > /var/www/sites/example.com/backups/db_backup_"`eval date +%u%m%Y`".sql Now the…
Alex
  • 209
  • 5
  • 12
2
votes
3 answers

bash + how to match string that include characters and numbers

please advice - what's wrong with my syntax ? ( should not print the "bad interface " ) remark - I work with bash shell ETH_NAME=eth0 ( or any other as eth1 or eth2 .... ) echo $ETH_NAME eth0 [ $ETH_NAME != eth[0-9] ] && echo bad…
yael
  • 2,433
  • 5
  • 31
  • 43
2
votes
2 answers

How to avoid syntax error on missing command line arguments?

How to avoid syntax error on missing command line arguments? Example shell script: var1=$1; var2=$2; echo $var1 echo $var2 var3=`expr $var1 + $var2`; echo $var3 Output : shell>sh shelltest 2 3 2 3 5 Output : shell>sh shelltest expr:…
Ahn
  • 181
  • 3
  • 5
  • 13
2
votes
1 answer

Stream tar.gz file from FTP server

Here is the situation: I have a tar.gz file on a FTP server which can contain an arbitrary number of files. Now what I'm trying to accomplish is have this file streamed and uploaded to HDFS through a Hadoop job. The fact that it's Hadoop is not…
2
votes
1 answer

shell variable value not storing inside file

I wrote following script, which generate random password and store it in file pass1=/tmp/a Above script printing generated password through "echo $pass1" command. But nothing…
vnix27
  • 886
  • 2
  • 11
  • 19
2
votes
5 answers

bash + print line every 10 min in bash

I want to print by echo the following "still in process wait another 10 min" every 10 min Please advice what condition needs to add before the echo command in order to print this line every 10 min? Remark - counter increase by one every cycle (1…
yael
  • 2,433
  • 5
  • 31
  • 43