shell

Consistent implementation of tr?

I have a ksh script that generates a long, random string using /dev/urandom and tr: STRING="$(cat /dev/urandom|tr -dc 'a-zA-Z0-9-_'|fold -w 64 |head -1)" On the Linux and AIX servers where I used this it resulted in 64 characters of upper and lower case alpha chars, digits, dash and underscore characters. Example: W-uch3_4fbnk34u2nc0...

Preserving argument spacing, etc when passing into mvn exec:java

I have a shell script that launches a Maven exec:java process - exec mvn exec:java -Dexec.mainClass=... -Dexec.args="$*" Now sadly if I run ./myMagicShellScript arg1 "arg 2" the single string arg 2 doesn't make it through as a single argument as I'd like. Any thoughts as to how to escape / pass things through properly (perferably ...

what do i need to do to make my c++ program run by only entering the name on my unix system

Possible Duplicate: Code wont run. [not] I have written and compiled a program and i want to make it so that from shell i can just type programname to make it run instead of going to the directory the the program is in and typing ./ before the program name. If this is possible please let me know. ...

shell command: need help about a regex match

I have a sentence that I want to write a shell command to grep it from a text: The sentence is: self.timeout=2.0 However, as this is a part of code from a file. so it this sentence could also be self.timeout = 2.0 or self.timeout =2.0 or self.timeout = 8.0 that is: there may be blanks besides "=", and the value of self.timeou...

Enable History Logging In TCSH Shell

How can I enable logging of all the commands entered in the tcsh shell? I've tried: Setting the $history variable to 100. The $savehist to 99. Set the $histfile to $home/.history Typing commands into the shell doesn't save the commands in the history file. ...

How to share bash/shell code snippets taken from command prompt with syntax coloring

Hi there. I'm looking for some way to share code snippets taken directly from command prompt. For example: plinjasa@pllzpc029 ~ $ ls plinjasa@pllzpc029 ~ $ mkdir maindir plinjasa@pllzpc029 ~ $ ls -l total 0 drwxr-xr-x+ 1 plinjasa Domain Users 0 2010-08-26 15:22 maindir plinjasa@pllzpc029 ~ $ cd maindir plinjasa@pllzpc029 ~/maindir ...

parsing xml with applescript or maybe shell

I need t parse xml for an applescript project and i got a start but for some reason my code is not operating the way I expected it to it does find the item I'm looking for but does not return a value here is the code set xmlFile to ((choose file without invisibles) as string) tell application "System Events" set xdata to XML elem...

Windows Kiosk App

So, I need to build a kiosk type of application for use in an internet cafe. The app needs to load and display some options of things to do. One option is to launch IE to surf. Another option is to play a game. I've been reading that what I probably want to do is replace the windows shell and have it run my app when the OS loads. ...

Regex: Help with extracting a filed from the text and replace the value of the field

I have to extract a parameter from a configuration file, and replace its values with another given value. The config file is: <host ip="200.200.200.200" name="testhost" description="test server" type="TEST_Duplex " connection="xmlrpc" xmldefaulttimeout="2.0" xmlspecifictimeout ="8.0"/> I have to replace the value of xmldefaulttimeout=...

Memorizing *nix command line arguments

For my developer work I reside in the *nix shell environment pretty much all day, but still can't seem to memorize the name and argument specifics of programs I don't use daily. I wonder how other 'casual amnesiacs' handle this. Do you maintain an big cheat sheet? Do you rehearse the emacs shortcuts when you take your weekly shower? Or i...

how to print a section of file between two regular expressions only if a line within the section contains a certain string within it

Hi I have a file of events that has multiple multi lined events between <event> and </event> tags. I want to print out the entire event From <event> to </event> only if a line within that event contains either the string uniqueId="1279939300.862594_PFM_1_1912320699" or uniqueId="1281686522.353435_PFM_1_988171542". The file has 100000 eve...

What does the $# construct mean in bash?(and in general I suppose)

I see foo() { if [[ $# -lt 1 ]]; then return 0 fi ... } What exactly is it comparing by using $# as it does there? ...

Convert ascii code to hexadecimal in UNIX shell script

I'd like to convert ASCII code (like - or _ or . etc) in hexadecimal representation in Unix shell (without bc command), eg : - => %2d any ideas ? ...

ipython shell awk : Escaping "$" sign

Hi I am figuring out the Ipython shell support. Its seems awk doesn't work i.e following command !ls -l | awk '{print $1}' just prints "1". How do I pass the "$" sign correctly to shell. I am using zsh. Thanks Sandeep ...

PHP exec rm -Rf not working for subdirectories

I am trying to delete all contents in specific folder but it doesn't seem to effect subfolder but it should, because bash command does it from console. system('rm -Rf some_dir/*'); ...

sh/expect/sudo/screen all needed together in one command.

What I need to have happen: PHP needs to launch an server app which has root permissions running in the background. All of this should be silent. -Sudo is needed to allow php to perform an op that requires root permissions. -Screen is required to allow the app to run outside the scope of the webpage which started the process. -Expect ...

Run shell commands with PHP?

Occasionally my media server goes down and I'm wondering if it's possible to start it remotely using php to check the port and if it's not running invoke cron (or some other way) to run a shell command. Is this possible because this is not a strong area for me. Here's the process I use with PuTTy. login to shell cd to source/red5/dis...

UNIX untar content into multiple folders

I have a tar.gz file about 13GB in size. It contains about 1.2 million documents. When I untar this all these files sit in one single directory & any reads from this directory takes ages. Is there any way I can split the files from the tar into multiple new folders? e.g.: I would like to create new folders named [1,2,...] each having 10...

Shell script to rename files

I wrote a small shell script based on an example I found here: https://bbs.archlinux.org/viewtopic.php?id=36305 it takes this: bash-3.2$ ls test 001 test 002 test 003 test 004 and turns it into: bash-3.2$ ls 001 002 003 004 rename.sh However it gives me this error (even though it works): bash-3.2$ ./rename.sh mv: missing d...

Creating a shell script to run Java program

Hi I used a shell script to run a Java class. My script contains #!/bin/sh java -jar jobs/job.jar These are my failed attempts to run it. [root@]#sh testapp.sh Unable to access jarfile jobs/job.jar if I just do this at the command line it works fine [root@]#java -jar jobs/job.jar thanks. ...