A shell script is a script written for the shell, or command line interpreter, of an operating system.

learn more… | top users | synonyms (1)

0
votes
2answers
127 views

Can running a script for many days harm my computer?

I have made some BASH scripts which take 24 to 48 hours to completely run on my netbook. They mostly make use of sed and awk and are constantly editing some files. If I run these for such a long time, ...
5
votes
3answers
2k views

How to script a database migration using an SSH tunnel?

I am trying to create a sync.sh script that coordinates with our less-than-ideal version control for our website. This script will migrate a live copy of the database to our development environment ...
1
vote
1answer
854 views

Shell script commands not executed after SSH login until exit from SSH

I'm new to shell scripting and I tried to have a script ssh into another machine and perform some commands. I have the public/private key set up so I'm not prompted for a password when I ssh into the ...
0
votes
2answers
162 views

How to replace a command with the result of another in linux?

I want to create a command which uses the result of another like this: JNLP_FILE='find . -name viewerApplet.jnlp' cp ${JAR_FILE} ../../sign-jar/$PROFILE/ But I don't know how to execute the find ...
5
votes
2answers
3k views

How to extract a complete list of extension types within a directory?

Within a directory, and recursively within it's sub-directories, meaning every directory within a directory is processed, how do I compile a complete list of unique extensions within the directory? ...
2
votes
1answer
138 views

How do I tell an app that the home folder is located somewhere else?

Here's the basic script from a batch file. I'm trying to do something similar to this, but on Linux that would tell Minecraft(Java) that the home folder was located somewhere else (like a flash ...
1
vote
1answer
612 views

How to continuously execute an application with cmd with Windows Server?

this is my requirement: I need to execute an endless script continuously. The script never ends by itself but if someone closes it I need to launch it again (can be a delay between the close and the ...
0
votes
3answers
932 views

Shell script to get the response from server

We are testing our server. I am a beginner to shell scripting. I need an bash shell script, to read a text file having URLs, query each URL to the server and check whether the application server ...
1
vote
1answer
850 views

shell scripting grepping for pattern and then echo message

I have a file which has the below pattern ================================================= 4601 -- it means completed 4602 -- it means failed 4603 -- it means timed out ...
3
votes
2answers
436 views

How to search *upwards* for file? (reverse find)

I'd like to search "upwards" for a file in shell script, e.g. check $PWD, then $PWD/.., then $PWD/../.., etc. until hitting the root. Before I go and roll my own, is there some builtin bash/zsh/find ...
4
votes
1answer
2k views

Why use parens instead of backticks for executing a command 'in situ'?

I have recently started to shift my shell scripting from utilizing backticks to parens to execute a command in situ and use the results in something else. Eg: for line in `cat file` do echo ...
0
votes
1answer
301 views

grep + match quantity and numbers

with the following command I can verify/match if param have numbers or "." param=2.3.1 echo $param | grep [0-9][.] but what I need to add in my syntax in order to verify also if I have at ...
1
vote
2answers
2k views

Can I encrypt a username password combo before using it with cURL?

I'm making a shell script that reached out to a web service with basic auth. I don't want to have to put in my username and password every time the script runs, but I also don't want to have the combo ...
0
votes
1answer
62 views

Execute Script when leaving a window

is it possible to execute a Script (Applescript/Shellscript) when I leave a window (and when I switch back to it)? What I want to do: I want to pause my VM when I leave the VM-Window (vmrun pause ...
1
vote
1answer
467 views

solaris + egrep command syntax not work

my target is to match snmpmanager string from /etc/hosts file in Solaris machine I don’t get any match output from the following command (but snmpmanager already defined in host file) why?? egrep ...
1
vote
1answer
2k views

How can I write a cron job to archive my log files every night?

I assume this is relatively easy but my shell scripting isn't that great so I'm hoping to get some help. I have a task which runs every hour and appends its output to a log file. I'd like to move ...
-2
votes
0answers
50 views

Create an executable from a shell script in OS X [duplicate]

Possible Duplicate: Can I create a configuration file for a shell script? I need to create an executable from shell (.command) in OS X, with parameters. Example: backup -s1 -s1 is ...
1
vote
4answers
235 views

Learning Shell Script, What's Next? [closed]

I've had finished learning "Shell Script" in Linux so I'm now intermediate near advanced level but I can't guess how can I use this scripting language to make things/tiny programs! Just as having the ...
0
votes
1answer
320 views

usermod + awk invalid syntax

I have been trying to write a command (Solaris server) that adds a user to a specific group. It's a pretty long command so I'll post the whole command here and then break it down. USER=myUser ...
0
votes
3answers
111 views

Process plain text data

I've this plain text file that I need to be automatically examined and results written in another plain text file. Note that I'll use plain text and CSV interchangeably, since CSVs are plain text ...
1
vote
2answers
113 views

Brace expansion substitution?

I've made a small bash script to automatically split my two monitors with imagemagick when I take a screenshot. #! /bin/bash convert "$1" -crop 1024x600+0+0 +repage "${1//.png/}-left.png" convert ...
3
votes
2answers
184 views

hardlinking takes a lot of space

I made an rsync incremental backup script for my server that will copy a MySQL database backup and a specified folder path to a remote server. Here's the code on Github. Code excerpt from lines ...
1
vote
1answer
164 views

Identifying a file with “file” in a shell script?

I'm currently writing a shell script that needs to be able to identify the actual type of files (not their extensions) with the unix "file" utility. However, that tool outputs human readable text ...
2
votes
1answer
655 views

Run HTML Tidy in batch on Mac OS X?

I want to run HTML Tidy on a large number of files located in folders and subfolders. I can use the following command in Terminal to run it on a single file: tidy -f errors.txt -m -utf8 -i ...
5
votes
1answer
5k views

Why do I Get [[: not found When Running a Script?

I'm trying to write a script that has to check if a file exists. In the console I write if [[ -a /path/to/file.txt ]]; then echo "not mod"; else echo "mod"; fi and I get not mod but when I write ...
1
vote
3answers
3k views

shortcut for opening cmd.exe at a certain location

How can I create an icon\shortcut to a script that opens cmd.exe command prompt at a certain location on a certain drive under Win7?
0
votes
1answer
1k views

Downloading multiple files with wget and handling parameters

How can I download multiple files using wget? I also want to rename the files. Here are the commands I'm running one by one (copy/paste on terminal): wget -c --load-cookies cookies.txt ...
7
votes
7answers
63k views

How can I run a shell script in Windows?

I'm a Mac user and new to Windows. How can I execute a shell script in Windows? Generally, I would save the text file with the extension .sh and run it via Terminal. But how could I do that in ...
0
votes
2answers
566 views

Downloading files from FileSonic via terminal without a premium account

I found various blogs on the internet about how to download a file from FileSonic, Hotfile, Rapidshare, etc. from a Linux terminal if you have a premium account. Is there any way to download a file ...
8
votes
3answers
618 views

How can I run my python program directly from the shell?

I wrote a script. When it starts, it won't stop, and it keeps getting data from the Internet. I can call it this way: cd /User/Desktop/project/internetScanner/ python3 main.py start But I would ...
1
vote
1answer
483 views

Linux shell script: copy a (text) file and replace a token with a path

I need to create a text file where parts of it should be replaced by any arbitrary path. I wanted to do that by copying a template file and then replace a special pattern, e.g. ${MY_PATH} with the ...
0
votes
1answer
4k views

How declare and assign value to a variable in shell script?

I need to have two variables and want to perform an addition with these variables in shell script. I am using the below script for this, but I get an expr: non-numeric argument error while running ...
2
votes
1answer
185 views

How to create a listener for a forked process?

I want to create a pair of bash functions something along the lines of function generator { while [ 1 -le 1 ] do # run log generator > somefile.log done } function tail_log { ...
2
votes
1answer
405 views

Have the at command return the job id of the task just submitted

Is it possible to have the at command return somehow the job id it just submitted when used from within a script? (kind of like $? retrieves the last exit code or $$/$! retrieve the PID of the command ...
0
votes
1answer
467 views

UNIX script to find dirs that contain a specific file (pom.xml) then execute a maven command on it

I'm new to scripting so please bear with me (if you can). I want to do something similar to this question but the 'root' directory will be different for different users on different OS (there can't ...
1
vote
1answer
168 views

How can I view the full exception thrown by a script in the shell?

When I'm running my ruby script, I'm getting an exception. However, since I'm running Ubuntu in VMware Fusion, I can't resize my terminal window so I can't see the whole excecption. How can I view ...
3
votes
1answer
503 views

Custom multi-item context-menu entry for Windows Explorer

I'm trying to create a custom context-menu entry for Windows (7) Explorer that will send ALL selected items ton ONE single command. I've read about MultiSelectModel with a Player value in MSDN Doc ...
1
vote
0answers
1k views

Macintosh OS X Logout Script

I am working on a project where I need to implement a logout script on some Macintosh computers. I have read the following Create a logoff script/task for Mac OS X article and found that while it is ...
0
votes
3answers
1k views

Check if string equals asterisk in Bash scripting?

I'm making a bash script to do basic arthmetic and when I do: if [ $2 == "*" ] it does not work. How can I check for asterisk?
6
votes
5answers
10k views

Run a shell script on OS X without having a terminal window appear?

I'm trying to set up a few keyboard shortcuts that open specific iTerm sessions, which I was able to do with BetterTouchTool and a bit of AppleScript magic. The problem is that OS X insists to open a ...
0
votes
1answer
5k views

Shell script to read value from a file and compare it to another one

I have a C program which puts one unique value inside a test file (it would be a two digit number). Now I want to run a shell script to read that number and then compare with my required number (e.g. ...
1
vote
3answers
2k views

How do I delete a certain line from a file with Perl?

How would I delete the line [[ -f /var/tmp/Li.ksh ]] && /var/tmp/Li.ksh from a file by a perl command in a ksh script? I tried: perl -i -pe "s/[[ -f /var/tmp/Li.ksh ]] && ...
1
vote
1answer
639 views

How to avoid duplicates when copying files that have been renamed at the destination

I have to get pictures from a folder – with subfolders which are updated automatically – with their extensions. These files have to be copied in a folder where a website based on PHP will edit them ...
2
votes
2answers
902 views

Bash script: rename all files below a directory?

Here's what I'd like to do in pseudocode: for subdir in [all first-level subdirectories of the current directory]: for file in [all files in subdir]: rename file to "myprefix_" + ...
1
vote
1answer
76 views

Writing scripts for use on multiple system with change in some variables etc

The title may not be much clear. I have written some scripts for housekeeping tasks on the Ubuntu servers we maintain. When ever there is a new deployment for a client, I have to change user ids, ...
2
votes
2answers
5k views

Echo multiple lines of text to a file in bash?

How do I write: $count = mysql_num_rows($result); print "<h3>$count metal prices available</h3>"; to a file, index.php? I've tried: echo "$count = mysql_num_rows($result); print ...
0
votes
1answer
209 views

Authenticate connection to remote repository before committing files

All, I have an app (using shell script) that automates the process of committing to svn , generating svn info and emailing it. But every now and then I get the following Authentication realm: < ...
3
votes
2answers
432 views

Automatically reconnect interactive SSH session

What's the best way to automatically reconnect an interactive SSH session to re-establish the shells on terminals? I looked at autossh but that seems to be dedicated to port forwards (which I do not ...
0
votes
0answers
188 views

CScript Terminates before completing task

I am using the below with mods but ziping several Gb of info the last command is Wscript.sleep 2000. I have extended this to 20,000 and 200,000 but I use the script vor various diferent sizes. Is ...
0
votes
1answer
923 views

Trap ctrl-z key to perform cleanup

All, I have a shell script where I want to call a function to do some cleanup if user presses the ctrl-z key(SIGTSTP signal). I read about the trap command and found an example where I can trap the ...