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

How to call perl from crontab?

I can run this command fine from the SSH console of my rackservers shared hosting: cd /home/myaccount/public_html/whatever; perl -w -I/home/myaccount/public_html/whatever rss2txt.pl http://whatever.com/feed But when I enter the same command as a…
harvest316
  • 115
  • 8
1
vote
3 answers

Do I need to add 'sudo' for mysqldump command, for the MySql backup script

I am trying to write mysql backup script for cron. Using Ubuntu server. Current code is as below: #!/bin/sh mysqldump -u root --all-databases > /root/all_databases_backup-`date +%A`.sql Do I need to add 'sudo' before mysqldump, like…
gilzero
  • 439
  • 4
  • 9
  • 20
1
vote
1 answer

Safely execute custom script parts as sudo

In /usr/local/bin I've the following script called sdown /usr/local/bin$ cat sdown #!/bin/bash if [ $# -lt 1 ]; then echo "no time set" else sudo shutdown -h $1 fi Permssions are 788: -rwxr-xr-- user user sdown The point is if I run the…
nuala
  • 168
  • 6
1
vote
1 answer

tput command + bold specific strings in file

please advice how to bold the "Date & Time" numbers from the following file with tput command ( I have Solaris machine) for example I want to bold only the "24-09-2009 16:17:45" etc for all other date and time the tput will write in my ksh script…
yael
  • 2,433
  • 5
  • 31
  • 43
1
vote
3 answers

How do I add a line to a specific stanza in a config file?

My configuration file, server.conf, has the following format: [general] setting1=sdfdsf setting2=asdfadsf [ssl] setting1=sadfsdf setting2=sdfadsfkljasdf How do I add an additional setting to the [general] stanza using a Bash script?
travis1097
  • 113
  • 1
  • 3
1
vote
2 answers

Script Shrew VPN

I have the Shrew client installed in order to connect to a cisco VPN. (side note: anyconnect royally blows and I spent several hours trying to get it to work; I had shrew running within 2 minutes of installing it.) Anyway, I can connect just fine…
NotMe
  • 3,772
  • 7
  • 31
  • 43
1
vote
2 answers

Can't pass path to shell script

I'm new to OSX, and don't use the commandline that often. I'm trying to use a script to do some automatic deployment, but when I execute the script it is looking for a directory. I tried: sh myscript.sh '/Users/profiles/Desktop/Development' sh…
cinqoTimo
  • 247
  • 5
  • 15
1
vote
5 answers

write in all lines plus one

Can you help me with a unix script to get result like this in file: apple1 apple2 apple3 etc.. till 100 from a file apple.txt which contains only one word - apple. Thank you in advance!
ampersand8
  • 13
  • 2
1
vote
2 answers

How to untar a single file from an archive with randomly generated directory names?

I'm trying write a script that will download a tarball from github and extract a single file from it. However the top level directory inside the tarball has some random characters in it, which I think change when the repo/tarball is updated,…
bgibson
  • 121
  • 4
1
vote
4 answers

A script that verifies that Apache (or any account) has proper permission to navigate to a directory

It seems that Apache needs at least read and execute permission to all the sub-directories of a path in order to serve the files in the directory. Does anyone have a script or one-liner that could verify this? I was thinking perhaps a bash script…
Belmin Fernandez
  • 10,799
  • 27
  • 84
  • 148
1
vote
3 answers

Logging with timestamp

I am trying to prepend log entries with a timestamp, but the generated timestamps do not seem to change over time: #!/bin/sh NOW=$(date +"%Y-%m-%d %H:%M:%S") echo "$NOW Logging something" sleep 2 echo "$NOW Logging something else" Output for…
Bertolt
  • 297
  • 3
  • 10
1
vote
1 answer

How to verify application up or not?

I would like to write a script to check whethere the application is up or not using unix shell scripts. From googling I found a script wget -O /dev/null -q http://mysite.com, But not sure how this works. Can someone please explain. It will be…
Selvakumar P
  • 305
  • 2
  • 8
  • 16
1
vote
1 answer

ssh + multiple ssh connection failed

I have 47 Linux client machines and one Solaris server machine (all Linux client machines are red-hat 5.1) all clients perform ssh connection to the server in order to verify if /tmp/generic_error.txt exist in the server clients do the ssh…
Eytan
  • 611
  • 6
  • 13
  • 27
1
vote
1 answer

Linux shell script - Is it possible to capture the output of a command and use it in another command

So I want to automate the process of uploading a file to Rackspace. Here's what I need to do: First, I type: curl -D - \ -H "X-Auth-Key: 123456789abcdefghijk" \ -H "X-Auth-User: MyUsername" \ …
Mike Christensen
  • 965
  • 1
  • 11
  • 21
1
vote
3 answers

How can I recursively delete old files and prune resulting empty directories?

We're using an AIX server to house thousands and thousands of little files in a nested directory structure. I'm trying to write a script that will recursively delete old files, and then delete the containing directory if that was the last file in…
JeffK
  • 113
  • 1
  • 6