shell

Shell script to count files, then remove oldest files

I am new to shell scripting, so I need some help here. I have a directory that fills up with backups. If I have more than 10 backup files, I would like to remove the oldest files, so that the 10 newest backup files are the only ones that are left. So far, I know how to count the files, which seems easy enough, but how do I then remove...

How do I launch a subprocess in C# with an argv? (Or convert agrv to a legal arg string)

I have a C# command-line application that I need to run in windows and under mono in unix. At some point I want to launch a subprocess given a set of arbitrary paramaters passed in via the command line. For instance: Usage: mycommandline [-args] -- [arbitrary program] Unfortunately, System.Diagnostics.ProcessStartInfo only takes a st...

find: missing argument to -exec

Hello all, I was helped out today with a command, but it doesn't seem to be working. This is the command: find /home/me/download/ -type f -name "*.rm" -exec ffmpeg -i {} -sameq {}.mp3 && rm {}\; The shell returns find: missing argument to `-exec' What I am basically trying to do is go through a directory recursively (if it has oth...

How to run command in the background and notify me via email when done

Hello all, I have the following command which will take ages to run (couple of hours). I would like to make it a background process and for it to send me an email when its done. For the cherry on the top, any errors it encountered should write to a text file when an error has occurred? find . -type f -name "*.rm" -exec ./rm2mp3.sh \...

Visual Studio 2010 Shell Isolated template broken

I am following a tutorial for creating a Visual Studio Isolated Shell application. When I get to step number 4 I a dialog with the following text: A problem was encountered creating the sub project 'VSShellStub1'. The template specified cannot be found. Please check that the full path is correct. I've tried this on two separate m...

Find maximum positive integer value in Bourne Shell

I'm checking a counter in a loop to determine if it's larger than some maximum, if specified in an optional parameter. Since it's optional, I can either default the maximum to a special value or to the maximum possible integer. The first option would require an extra check at each iteration, so I'd like to instead find out what is the m...

Source code for shell commands in linux (C language)

Hello guys, Currently, I'm implementing a simple shell in C language as my term project. I used fork and exec to execute the commands. However, some commands must be executed internally (fork and exec aren't allowed). Where can I find the source code for the shell commands? ...

Alternative to scp, transferring files between linux machines by opening parallel connections

Hi, Is there an alternative to scp, to transfer a large file from one machine to another machine by opening parallel connections and also able to pause and resume the download. Please don't transfer this to severfault.com. I am not a system administrator. I am a developer trying to transfer past database dumps between backup hosts and ...

What is the correct configuration for %autoreload in a Django ipython shell?

Ipython has a plugin called autoreload that will presumably reload all your modules after every command, so you can change the source and not have to quit the shell and reenter all your commands. See http://dsnra.jpl.nasa.gov/software/Python/tips-ipython.html for example. However, this seems flaky at best when using it with Django, e....

caching problem

I wrote one script which is running on the linux machine.It fetches data from one url and displays the content on a page. The problem I am facing is some time if I refresh the page 4-5 times it displays the old content and not the latest one. The problem could be because of caching proxy which is still caching old content. Please tell m...

How to prepend/(insert a string) in a file at arbitrary line numbers to multiple files in a directory?

Appending can be done using tee command. cat file | tee -a >> * Is there a way to do a prepend/insertion? Thanks. ...

How do I check if all files inside directories are valid jpegs (Linux, sh script needed)?

Ok, I got a directory (for instance, named '/photos') in which there are different directories (like '/photos/wedding', '/photos/birthday', '/photos/graduation', etc...) which have .jpg files in them. Unfortunately, some of jpeg files are broken. I need to find a way how to determine, which files are broken. I found out, that there is t...

Deleting a folder that contains symlinks

If I rm -rf a folder that has soft links in it, will it try to follow those links and delete the corresponding folder, or will it simply unlink them? I have a copy of my home directory with sym links in it, and I'm scared to rm -rf it in case it follows those links and blows up the corresponding folders... ...

Installing a Python app when you do not have shell access?

I know PHP but I do not know Python. I need to install a Python app to a shared hosting (where I do not have shell access). What steps should I follow? I have: Apache, PHP, cgi-bin, Python, Perl, cPanel, FreeBSD ...

BASH: Checking for environment variables

Hi folks, I am trying to check the value of an environment variable and depending on the value do certain things and it works fine as long as the variable is set. When it isn't though I get a whole bunch of errors (as BASH is trying to compare the string I specify with an undefined variable, I guess) I tried implementing an extra check...

input of while loop to come from output of `command`

#I used to have this, but I don't want to write to the disk # pcap="somefile.pcap" tcpdump -n -r $pcap > all.txt while read line; do ARRAY[$c]="$line" c=$((c+1)) done < all.txt The following fails to work. # I would prefer something like... # pcap="somefile.pcap" while read line; do ARRAY[$c]="$line" c=$((c+1)) done ...

Shell scripting : Find file with the name 'error_log' and check sizes, remove if over a certain size

Hi guys, I am trying to create a shell script/command that find error_log files created by PHP, check their file sizes and remove them if over a certain size. I have only gotten as far as printing the files and file sizes with the code below for i in `locate -r 'error_log$'`;do echo "$i|" `stat -c %s $i`;done Can anyone help? Thank...

Cygwin GCC + WinXP cmd.exe does nothing

My basic problem is that if I run GCC from the windows command line (cmd.exe in Windows XP) and it does nothing: no .o files are created, no error messages, nothing. It will only throw an error message if I use DOS-style paths, but nothing else. When I run from the Cygwin shell then it will throws error messages as appropriate for the ...

OpenOffice Calc Macro: Run shell command and return output as result of custom function

I would like to write a custom OpenOffice function that runs a shell command and puts the result into the cell from which it was invoked. I have a basic macro working, but I can't find a way to capture the command's output. Function MyTest( c1 ) MyTest = Shell("bash -c "" echo hello "" ") End Function The above always returns 0....

Autorun a removable device in Linux

I have a removable device setup so it autoruns when plugged into a Windows machine and pops up a message giving the owner's information, so it can be returned if lost. Is there a way to do this in Linux as well? It doesn't need to be complex, it can be an option in a right-click menu, or a splashscreen, or anything. ...