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
0answers
244 views

Workaround for ENOTTY while running a c process from script?

What's the issue? Getting a ENOTTY error on a function call tcgetattr() when the process is invoked from a script. The error comes only when ran from the script. If it is run from an interactive ...
2
votes
4answers
246 views

Parsing command line output delimited by underscore

I've got some command which output looks like that: some_command Current view: username_token1_token2_token3_4_token4_2 How could I parse the "token3_4_token4_2" part out of the string?
1
vote
2answers
2k views

cp into destination hierarchy with symbolic link?

I am trying to write a site deploy script that will copy files like so: SOURCE . .. src/ html/ DEST . .. src/ html/ -> /var/www/ftproot/mysite I want the files in SOURCE html to go to DEST ...
4
votes
1answer
1k views

Where to store cronjob script?

I'd prefer to not keep it in my /home/myusername directory. Is there a best practice of where to store your shell scripts for cronjobs? At the root level? I'm running ubuntu server 12.04 right now.
2
votes
1answer
86 views

How to list all scripts called by a master script?

I want to list all scripts (recursively) which are being called by a master script. For example: master.sh a.sh >> this script calls a1.sh, a2.sh, a3.sh etc b.sh >> this one calls b1.sh, ...
-5
votes
1answer
300 views

How to copy a list of files from one directory to another and modify the destination file name on the fly

Could you propose a way to copy a list of files from one directory to another. During copying the script should capitalize the first letter of the filename and lowercase all other letters.
0
votes
0answers
160 views

rsync shell script

Need some hints on my first shell-script using rsync. I use rsync, because I had some trouble with a graphical Backup that ran twice and now I want this example as shown below to work on two external ...
0
votes
1answer
2k views

executing a shell-script through makefile

i am trying to create a .deb file that first installs the dependency that is stored in the some folder, for that i have created a shell script. My issue is executing the shell script through make file ...
0
votes
1answer
321 views

Identify text/ASCII files in Linux/Solaris

I have a little project to build a bash script that searches the OS (Linux/Solaris) for the current IP address in files, and replaces them with another IP address. The problem is that IP address ...
0
votes
1answer
125 views

for loop non-ending, loop never procedes to second argument

I am trying to use the "for name in" to loop through a list of values. It uses the first value in the line but sticks in a never-ending loop. #!/bin/ksh set -x # created 7 JAn 2013 by L Cooper # ...
1
vote
1answer
602 views

Handling whitespaces in the name of a ZFS dataset in a shell script

I'd like to take output from two commands – zpool list zfs list and for each found pool: zpool get all nameofpool and for each found file system: zfs get all nameoffilesystem Background and ...
0
votes
1answer
493 views

Determining if an argument looks like a valid path

I'm writing a bash script that needs to perform some operation on an argument which is a path The path may or may not correspond to an existing file on the user's system, so I'd like to test whether ...
0
votes
1answer
31 views

Environment auto-install

When I work, I often have to switch computers or virtual machines which means that every time I switch, I have to set up my (Linux) environment again. My question is the following : Is there a tool ...
7
votes
2answers
4k views

How do I close a window from an application, passing the file name?

I’m trying to produce an Applescript-based shell command that tells the Preview application from Mac OS X to close a particular window. #!/bin/sh osascript <<EOF tell application "Preview" ...
7
votes
1answer
353 views

How to change the appearance of empty folders in finder using Automator?

I'm trying to use Apple Automator to label empty folders in a heirarchy. Basically, I start off a project with a heirarchy of empty folders and fill them as I work. I want a workflow to label all ...
1
vote
1answer
270 views

how to remove “downloading” or 0% complete torrents in rtorrent using bash script?

I have 10K torrents and 7K of them are going too slow. I would like to remove them but the rutorrent and rtorrent interface is unusably slow. I noticed that the info about rtorrent is kept in .session ...
0
votes
1answer
252 views

Check file name and filter it based on the date

I have many files one of my scripts generate daily. The file name structure resembles: capacity_data_2012-12-02.txt , capacity_data_2012-12-03.txt and so on... I want to create a script which would ...
0
votes
1answer
2k views

How to append text to a specific lines in a file using shell script?

I have a text file (file.txt) having content something like: foo1 3464 foo2 3696 foo3 4562 It contains the process and respective PID. Using shell script, I want to append a string (running/not ...
3
votes
1answer
772 views

Script-specific autocomplete in shell

I create a lot of little scripts to help me in my every day life. I would like to provide auto-complete for them, specially that I intend to share them with people. Now, I know I can create ...
-1
votes
2answers
2k views

Execute multiple commands in one line inside unix shellscript

The question is somewhat related to the question asked here, http://stackoverflow.com/questions/5130847/shell-multiple-commands-in-one-line, but the difference is, I need to execute the whole commands ...
3
votes
2answers
579 views

shell script - How to output the owner of a file

Is there a command to output the owner of a file, and nothing else? I suppose I could use ls and run it through sed, but if there is a better way, I would definitely use it. Thanks in advance.
4
votes
2answers
4k views

How to add commands of windows to local shell of XShell 4

XShell is a very powerful tools to ssh remote computers such as Unix/Linux. And it has built some internal commands for you to run within your Windows. Xshell:\> help Internal Commands: new: ...
1
vote
2answers
181 views

Hard linking directory structure somewhere else

I have one directory where files appear in. I want to run a script regulary that finds all files in that directory that have only one link to them, and hard link them in another directory. However, I ...
0
votes
1answer
472 views

Can setting the executable flag on an installation script lead to CRC check failure?

Recenty I have installed the VMWare Workstation for Linux on my Ubuntu machine and in the process of installation I have ran into a peculiar problem. The installer itself is some kind of archive that ...
0
votes
1answer
58 views

Excute for loop in subfolder

I have this command : for i in $(svn st | grep \! | awk '{print $2}'); do svn delete $i; done I would like to execute it to a subfolder without making a cd command. Is it possible ? Thanks !
3
votes
3answers
1k views

How to auto source a shell script?

How to make a shell script execute it's commands as source commands without having to use "source scriptname.sh" expression to launch the script? Basically what I want is to type ./scriptname.sh and ...
0
votes
1answer
1k views

How do I view the OS installation date on Solaris 10?

How can I find out the system installation date on Solaris? Objective is to verify the date and time that the OS was created (OS creation timestamp).
0
votes
2answers
268 views

How to start a local server and open it in a browser from a shell script

I have a test suite which runs in a browser (using QUnit, though that's unimportant). The test suite requires a local server running on a particular port. Running the tests currently involves a few ...
2
votes
2answers
2k views

Automatically mounting Truecrypt volumes at user login time

I need to mount a Truecrypt volume automatically at user login time. This volume is specific for each user. I'm not sure how to proceed since I'm not extremely familiar with Linux and the various ...
1
vote
0answers
228 views

Run program on kde logout

I have created a backup script and I want to run it in a terminal window (to view the progress) when I logout from kde. I used the autostart feature and that works but I'm unable to show a terminal ...
2
votes
1answer
819 views

Make shell script commands to abort after certain timeout

I have often a situation in Linux shell scripts that if a specific command takes too long to run e.g. due to a network problem the shell script should abort running this command. What best practices ...
0
votes
1answer
59 views

Documenting software-updates semi-automatically in MacOS X by parsing log files?

I'd like to document changes I made to my computer (running MacOS 10.6.8) to be able to identify the sources of eventual problems. Mostly I install updates when a software notifies me about a newer ...
0
votes
1answer
1k views

How do I create a “here document” within a shell function?

I'm working my way through William Shotts Jr.'s great The Linux Command Line on my Mac OSX 10.7.5 system. 90% of the linux that Shotts covers is close enough to Darwin that I can figure out or GTEM to ...
0
votes
2answers
160 views

Shell script: Copy folder with a new name

I'm trying to write this shell script to create in the parent directory a copy of the folders found in the current directory. So far, I wrote this: for folder in *; do mkdir ../$folder; done ...
1
vote
1answer
74 views

How to put a Number in to a plist with bash

I'm trying to update my com.apple.background.plist. It works but the "ChangeTime" needs to be a Number/Integer in order to work. I tried to place a -int into the code but it gives an error. ...
4
votes
1answer
2k views

When default shell is not bash-compatible, why do bash scripts not work well?

My default shell is fish, because it's a lot nicer. But often when I run scripts, I get errors that seem to be from the bash script being processed by fish. I think this is because the script writer ...
0
votes
2answers
3k views

Automounting SD card when inserted in Ubuntu

I am trying to write a BASH script that automounts an SD card once it is inserted in the card reader, then move all pictures to a folder in the HDD and renaming each file to the date and time the ...
0
votes
1answer
644 views

Unix shell script - cp -R doesn't copy contents behind symbolic links

I've got this ./image folder full of symbolic links to "real" folders. These "real" folder contain a series of images. ./image/stones -> somefolder/stones ./images/grass -> ...
0
votes
1answer
188 views

update terminal title from standard output of long running command?

I'd like to change the title of a terminal window during a long running command (for example: git svn fetch) with values greped from the output, whilst still writing to standard output. Is this ...
1
vote
1answer
4k views

How to execute multiple scripts when openvpn establishes?

I am using ubuntu 12.04 to connect an openvpn server. Two scripts update-resolv-conf and vpn-up.sh in /etc/openvpn should be executed then the connection established. The commands following added to ...
0
votes
3answers
1k views

Batch file to replace “.” with “-”

I need to preserve the file extensions and it needs to work through the subfolders. For example: "File.name.ext" should become "File-name.ext" I am a completely ignorant regarding shell script so ...
2
votes
2answers
158 views

Problems with Startup after Script runs to Shutdown Windows 7 PC

I have a simple .bat script to shutdown a kiosk style machine in our work shutdown -h -f this hibernates the machine and I have it running each evening as a scheduled job. However my problem comes ...
10
votes
2answers
3k views

Writing shell scripts that will run on any shell (using multiple shebang lines?)

I've just started getting deeper into shell scripting, and I've always just thrown my script in a file, marked it chmod +x and then done /path/to/script.sh and let whatever interpreter is the default ...
0
votes
1answer
2k views

Open a terminal window & run command, then close the terminal window if command completed successfully?

I'm trying to write a script to do the following: Open a terminal window which runs a long running command (Ideally) move the terminal window to the top left corner of the screen using xdotool Close ...
1
vote
1answer
765 views

BASH script not working on windows

So I made a bash script, that works on MAC perfect, but on windows even with cygwin and CURL installed doesn't work, here is the errors that I'm getting $ ./r.bash Project name: imiodrag ': not a ...
2
votes
1answer
269 views

Passing Return Key via Shell Script

I'm using phpseclib to run a shell script on my server at a given interval. That script involves using nohup. For whatever reason, if there isn't a user ready to send SIGINT or a return to nohup once ...
2
votes
1answer
1k views

How can I tell if the lock screen is active from the command line on OS X?

I have a cron script that I want to run regularly if I am logged into my Mac. I don't want it to run if the Lock Screen is up. Is there a way to check from the command line / Terminal if the Lock ...
6
votes
2answers
660 views

Efficient way to use all cores in bash or zsh script

If I want to process large number of files with command "do_something" which only can use one core, what's the best way to use all available cores assuming each file can be processed independently? ...
1
vote
2answers
167 views

Arguments passed on by shell to command in Unix

I've been going over this question and I can't for the life of me figure out why the answer is what it is. How many arguments are passed to the command by the shell on this command line:<pig pig ...
0
votes
1answer
342 views

PBS/Torque: very simple pbsdsh script with PBS_VNODENUM

I'm trying to submit the following very simple script to my cluster: #!/bin/sh #PBS -l nodes=3:ppn=8,walltime=00:01:00 #PBS -M eamorr@mydomain.com #PBS -j oe #PBS -m bae #PBS -N geophysics pbsdsh ...