shell-scripting

continuous integration based on maven2

Hi, I am trying to figure out how to setup continuous integration using maven. What I want is: Check for new stuff in SVN If changes are detected, check them out Build and deploy I think all of this can be pushed into some shell script to make it be invoked by cron. Thus we will have automated continuous integration (nightly buil...

Parsing data from traceroute command

I am trying to parse the "number of hops" value from the traceroute command and output it with a bash script. Any hints? Very new so thanks. My script looks like this so far: #!/bin/bash #parse traceroute for hops and output to stdout. echo -n "Enter a host name(like www.google.com): " read hostname traceroute 2>&1 $hostname|grep "...

Problem executing TCL script from Bourne Shell (redirection trouble)

I am working with VMD (a molecular dynamics visualization package) and I want to open VMD from a Perl script, run a Tcl script, print the output to a log file, then close VMD and return to the Perl script. The ordinary syntax to do this is: system("vmd -dispdev text -eofexit < program.tcl > LOG"); which breaks down as follows, as best...

FTP distribution script

I'm starting to write an (sophisticated) FTP distribution script, but I thought: this can't be! I'm reinventing the wheel! Reliably distributing files to remote servers under controlled conditions from a central location is as old of a task as computers are, damn it! Please someone prove me right. Google search on this subject is so br...

how to manipulate strings with shell-script

This is what I used: for i in `find some -type f -name *.class` I got: some/folder/subOne/fileOne.class some/folder/subOne/fileTwo.class some/other/sub/file.class next, I would like to get rid of the "some/" for each value of $i. What command can I use? Do I HAVE to save them into a file first? Thanks ...

how to use shell script checking last changed time of a file

I want to find if certain files are changed within the last three minutes in order to decide if the cp was successful, and if I should exit or continue the script. How can I do that? Thanks ...

get sub string in shell script

if I have a string like some/unknown/amount/of/sub/folder/file.txt how can I get only the the file.txt sub string, remove the front part, while the length is unknown. thank you EDIT: file name could be any length, and sub folders could be any levels. ...

How to filter files when using scp to copy dir recursively?

I need to copy all the .class files from server to local with all dir reserved. e.g. server:/usr/some/unknown/number/of/sub/folders/me.class will be /usr/project/backup/some/unknown/number/of/sub/folders/me.class the problem is, there are many other useless files such as .svn-base files that i don't want. how can i filter them so I only ...

How to Make a AIX shell script executable?

I write a simple shell script which could be run like this $ksh script1 But i donn't know how to execute it.Like $script1 thanks. ...

total size of the contents of all the files in a directory

When I use ls or du I get the amount of disk space each file is occupying. I need the sum total of all the data in files and sub directories I would get if I opened each file and counted the bytes. Bonus points If i can get this with out opening each file and counting. ...

writing to serial port with a shell script

I need to communicate with a serial device by sending it ascii characters. I know that in Linux you can use fopen() to write to a serial port, but I didn't know if you could do that from a shell. If not, is there another simple way to do this? ...

Problems with variable in Unix Shell script

Hey all. I have trouble passing a variable from inside a loop. Code: # find all output.txt that has been modified last 24h ... PROCESSED=1 find ${PROCESSED_DIR} -mtime -1 -name "output.txt" | while read i do # .. and compare those with TMP_TXT if diff $i ${TMP_TXT} > /dev/null then # If both are same EXIT search...

Redirecting STDERR in a Bash file results in a file created even when there is no error. Why?

I've created a small Bash script that does a MySQL data dump. Because the dump can be fairly large I put the process in the background and then wait for either an error or the log to show up in the file system. I have the following code: mysqldump main_db > /loc/to/dmp/file.sql 2>/loc/to/error/log/file.log & The problem is that I get ...

What is the correct usage of (nested | double | simple) quotes

Hi all, I'm sure this question may seem foolish to some of you, but I'm here to learn. Are these assumptions true for most of the languages ? EDIT : OK, let's assume I'm talking about Perl/Bash scripting. 'Single quotes' => No interpretation at all (e.g. '$' or any metacharacter will be considered as a character and will be printed ...

Shell script problem

Hi, In my shell script i have the following line: export PATH=$PATH:/home/$USER/somedir. Say im logged in as user mike . I need to execute the shell script as root, so i run it as sudo filename.sh, so $USER becomes root in my path in that case . I want it to be that of the user running the script, i.e. mike instead of root. Is there...

scripting ipython through django's shell_plus

I'm writing a shell script which runs a command through ipython with the -c option like this: ipython -c "from blah import myfunct; myfunct()" but I want to invoke ipython through django's shell_plus command so I can take advantage of all the stuff shell_plus automatically loads for me: $ ./manage.py shell_plus I can't just add "-c...

writing a bash script that checks for a few special parameters before passing on the rest to another command

i am writing a bash script which acts as a wrapper around another command. it needs to be able to understand all of the parameters the command understands, plus a few extra. for example, if the command understands -abc switches and i wish for my wrapper script to understand those plus a -d and -e switch, then i need a way to look for and...

Delete all files but keep all directories in a bash script?

Hi, I'm trying to do something which is probably very simple, I have a directory structure such as: dir/ subdir1/ subdir2/ file1 file2 subsubdir1/ file3 I would like to run a command in a bash script that will delete all files recursively from dir on down, but leave all directories. Ie: di...

What shell am I in?

If I'm in a shell script that has no shebang line… Hum, that doesn't matter, because indeed sh is always used. Maybe not so. Is there a command to identify the name/type of current shell, the path to the shell binary, and the version of the shell? I don't need all of that, but the more I can get, the better. I want something that has ...

ftp file from server1 to server2 in unix

i am a shell scripting noob. i currently have a cronjob that runs every 15mts and check to see if a file exists. If it exists, it takes the file and processes and then deletes it Now, instead of deleting it, i want to make a copy and ftp it to Server2 below is the delete script. i want to modify it so that it makes a copy of the file...