shell

graceful degradation for globbing on terminal

Whenever glob pattern match fails, it stops the whole job. For instance, $ mv *.jpg *.png folder1 && blahblah mv: cannot stat `*.jpg': No such file or directory *.png isn't moved to folder1 and blahblah is not run. And the script below works only for the case when both .[A-z]* and * succeed. #!/bin/bash cd $1 du -sk .[A-z]* *| sort...

How to run PHP exec() as root?

I'm trying to build a firewall manager in PHP, but when I execute, <?php exec('iptables -L'); ?>, the result array is empty. I have tried, <?php echo exec('whoami'); ?>, and the response is www-data (the user that Apache is using). What can I do to execute the exec function as root? (Preferably without changing the Apache user.) ...

Is there a command shell (like bash) view for Eclipse?

I am coding in Eclipse (on the Mac) and need to run OS shell commands from time to time. I have a lot of bash terminal windows open and it takes time and is distracting to find the right one for the programming session. The commands are not always the same, and I need to see the output, so something like an External Builder will not do...

How do I fetch the folder icon on Windows 7 using Shell32.SHGetFileInfo

I have the following code which works on Windows XP and Vista - both 32 and 64 bit: public static Icon GetFolderIcon(IconSize size, FolderType folderType) { // Need to add size check, although errors generated at present! uint flags = Shell32.SHGFI_ICON | Shell32.SHGFI_USEFILEATTRIBUTES; if (FolderType.Open == folderType) ...

Shell: simple way to get all lines before first blank line

What's the best shell command to output the lines of a file until you encounter the first blank line? For example: output these lines but do not output anything after the above blank line (or the blank line itself) awk? something else? ...

linux shell scripting: hex string to bytes

Lets say that I have a string "5a". This is the hex representation of the ASCII letter 'Z'. I need to know a linux shell command which will take a hex string and output the binary bytes the string represents. So if I do echo "5a" | command_im_looking_for > temp.txt can I open temp.txt, I will see a solitary letter Z. ...

Is the md5sum linux command working right?

According to Wikipedia, the md5 sum of an empty string is d41d8cd98f00b204e9800998ecf8427e I confirmed this with my md5 library However, when I run echo "" | md5sum in my linux shell, I get 68b329da9893e34099c7d8ad5cb9c940 - In fact, none of my hashes match the output of the md5sum command. Any thoughts on this discrepancy? ...

Add a shell and a menu on consoleline window

I created a win32 consoleline window, and now i managed to put shell icon of it on the right buttom corner of my desktop... But now i need to add a menu to it when i right click the icon... any body can help me with this hairy thing.. Thanx very much ...

find and replace a string in a set of xml files using shell commands

Hello Members. I have 1000 files in a directory. I'm on a solaris machine I want to replace the string " /example/test/temp " t0 " /testing/in/progress/ in all the xml files in my directory. any pointers will be great. thanks, novice ...

create an xml file using a shell script

I have a table with two columns column_1 column_1 12345 12345 73255 73255 71377 71377 Now i want to create an xml like <header> <value>12345</value> <value>73255</value> <value>71377</value> <footer> basically i need to use a select query and put any one of the fields into the values of xml. could you please suggest h...

What is wrong with this AWK script?

Basically, I am creating an XML file by taking the values from a column of a table. I am starting an AWK script from a shell script (ksh if it matters) like this: SQL_RESULT=`sqlplus -s ${CONNECT_STRING} << EOF ${SQLPLUS_SETTINGS} select customer_id from GD9_GENTH_CUST_SUBSCR; exit; EOF` FILE_LIST=`echo $SQL_RESULT|sed -e 's/\n/''/g'` ...

How to get folder thumbnail with alpha channel

There is a nice feature in windows - thumbnail view. So we can see not just folder icon but also small parts of thumbnails of files in the folder. When I tried to get a thumbnail, I got the following: C#, Shell api -> native bitmaps -> wpf bitmap(i think this part is not important) ...

How do I split up a line and rearrange its elements?

I have some data on a single line like below abc edf xyz rfg yeg udh I want to present the data as below abc xyz yeg edf rfg udh so that alternate fields are printed with newline separated. Are there any one liners for this? ...

Navigating in the python terminal

I want a 64-bit python interpreter on my Mac so I had to rebuild from source. However, with my own custom build interpreter I run into issues when I try to navigate when I run the interpreter from inside a shell. Typing python into the bash shell results in the familiar: Python 2.6.3 (r263:75183, Oct 23 2009, 14:23:25) [GCC 4.2.1 (Appl...

cat file with no line wrap

In *nix, how do I display (cat) a file with no line-wrapping: longer lines should be cut such that they fit into screen's width. ...

How to replace new lines with tab characters

hi i have pattern like below hi hello hallo greetings salutations no more hello for you i am trying to replace all new lines with tab spaces using the following command sed -e "s_/\n_/\t_g" but its not working . could nybody pls help? i need the solution in sed /awk. ...

What's the different between ` and ' in programming, such as MySQL and shells

phpMySQL use backticks ` to surround column names, and I've just see people use backticks in shell scripts. Is that the same if they use ' ? ...

View Mercurial log/status with less by default

Hi, Is there a way to make mercurial use less to show me the logs/diffs/whatever by default? Now mercurial just displays everything when I type 'hg log'. I suppose I can use aliases like 'hg log = less hg log' if I want to. I'm wondering if there're better solutions. ...

Register/Unregister COM dll verbs are not working in vista

I am trying to use the registry settings from this page to add two menu-items to the explorer context menu in vista to register and unregister COM DLLs. But for some reason they do not work. I have checked the registry using Regedit and the keys do exist on my system. I have also tried logging on and off the system several times but stil...

Cartesian product of two files (as sets of lines) in GNU/Linux

How can I use shell one-liners and common GNU tools to concatenate lines in two files as in Cartesian product? What is the most succinct, beautiful and "linuxy" way? For example, if I have two files: $ cat file1 a b $ cat file2 c d e The result should be a, c a, d a, e b, c b, d b, e ...