sh

Running a script after startx automatically [closed]

[亡魂溺海] 提交于 2019-11-29 10:34:46
With my Raspberry Pi, I managed to login pi user automatically, then start tomcat automatically and then start X server as well. For those interested, auto login: 1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1 instead of 1:2345:respawn:/sbin/getty 115200 tty1 in /etc/inittab and sh /home/pi/apache-tomcat-7.0.47/bin/startup.sh su -l pi -c startx exit 0 in /etc/rc.local Now, I'd like to launch a java program (jar file) that I made, automatically after server X has started. How could I do that? Thank you UPDATE: On my Rapsberry, as LXDE is used, http://wiki.lxde.org/en/Autostart

UNIX date: How to convert week number to a date range (Mon-Sun)?

让人想犯罪 __ 提交于 2019-11-29 10:05:09
I have list of week numbers extracted from huge log file, they were extracted using syntax: $ date --date="Wed Mar 20 10:19:56 2012" +%W; 12 I want to create a simple bash function which can convert these week numbers to a date range. I suppose function should accept 2 arguments: $number and $year, example: $ week() { ......... } $ number=12; year=2012 $ week $number $year "Mon Mar 19 2012" - "Sun Mar 25 2012" With GNU date : $ cat weekof.sh function weekof() { local week=$1 year=$2 local week_num_of_Jan_1 week_day_of_Jan_1 local first_Mon local date_fmt="+%a %b %d %Y" local mon sun week_num

Why does AWK not work correctly in a makefile? [duplicate]

送分小仙女□ 提交于 2019-11-29 09:26:42
This question already has an answer here: Escaping in makefile 2 answers NOTICE: Escaping not problem, sample from shell is only sample, in Makefile $$. GNU Makefile man says why it's doesn't work: Note that expansion using ‘%’ in pattern rules occurs after any variable or function expansions, which take place when the makefile is read. --Orig. question: In pure shell, the next script works correctly: echo "test2.cpp src2/test2.cpp src1/test1.cpp src1/test.cpp" | \ awk 'BEGIN{RS=" "}{if(NR == 1) f=$0; else if(match($0, f)) print $0;}' Filter is first: test1.cpp And it returns: src1/test1.cpp

strip comments from xml file and pretty-print it

眉间皱痕 提交于 2019-11-29 09:20:32
I have this huge xml file which contains a lot of comments. Whats the "best way" to strip out all the comments and nicely format the xml from the linux command line? you can use tidy $ tidy -quiet -asxml -xml -indent -wrap 1024 --hide-comments 1 tomcat-users.xml <?xml version='1.0' encoding='utf-8'?> <tomcat-users> <user username="qwerty" password="ytrewq" roles="manager-gui" /> </tomcat-users> Run your XML through an identity transform XSLT, with an empty template for comments. All of the XML content, except for the comments, will be passed through to the output. In order to niecely format

sh read command eats slashes in input?

∥☆過路亽.° 提交于 2019-11-29 09:06:41
Perhaps easiest to explain with an example: $ echo '\&|' \&| $ echo '\&|' | while read in; do echo "$in"; done &| It seems that the "read" command is interpreting the slashes in the input as escapes and is removing them. I need to process a file line by line without changing its contents and I'm not sure how to stop read from being smart here. Any ideas? Accrding to: http://www.vias.org/linux-knowhow/bbg_sect_08_02_01.html : -r If this option is given, backslash does not act as an escape character. The backslash is considered to be part of the line. In particular, a backslash-newline pair may

Bourne Shell Left Right Justify

三世轮回 提交于 2019-11-29 08:45:19
I am trying to do some formatting on output data in a script and not positive how to do Left Right justify as well as width. Can anyone point me in the right direction? you can use printf. examples $ printf "%15s" "col1" $ printf "%-15s%-15s" "col1" "col2" tools like awk also has formatting capabilities $ echo "col1 col2" | awk '{printf "%15s%15s\n", $1,$2}' col1 col2 You're not being very clear, but the easiest way is probably to just use printf() (the shell command, not the C function of the same name). Left align is kind of trivial, to get right align you can use printf and the envrironment

What's the point of eval/bash -c as opposed to just evaluating a variable?

大憨熊 提交于 2019-11-29 06:49:34
Suppose you have the following command stored in a variable: COMMAND='echo hello' What's the difference between $ eval "$COMMAND" hello $ bash -c "$COMMAND" hello $ $COMMAND hello ? Why is the last version almost never used if it is shorter and (as far as I can see) does exactly the same thing? The third form is not at all like the other two -- but to understand why, we need to go into the order of operations when bash in interpreting a command, and look at which of those are followed when each method is in use. Bash Parsing Stages Quote Processing Splitting Into Commands Special Operator

Problems installing Java EE SDK on Linux

拥有回忆 提交于 2019-11-29 06:09:25
问题 I installed the Java 6 JRE on my VPS just fine, but I can't get the EE SDK installation to even run. root@vps [/usr/java]# java -version java version "1.6.0_18" Java(TM) SE Runtime Environment (build 1.6.0_18-b07) Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode) However, when I try to run java_ee_sdk-6-unix.sh : ./ ../ java_ee_sdk-6-unix.sh* jre1.6.0_18/ jre.bin* root@vps [/usr/java]# ./java_ee_sdk-6-unix.sh Could not locate a suitable jar utility. Please ensure that you have Java 6 or

Find a file that was created within five days of another file in shell

て烟熏妆下的殇ゞ 提交于 2019-11-29 05:10:41
i'm still pretty new to scripting so stick with me and if you have any questions please feel free to ask. Okay, so: I have a file let's say file.txt file.txt exists in a directory /this/is/the/directory/file.txt In a separate directory .log files exist that tell me what happens when file.txt was created. fuubar.log, fuu.log, bar.log, this.log, that.log, some.log, other.log ...there is an unknown number of these logs. I need to gather all the log files that occurred +-5 days of the file.txt file being created. For example: file.txt was created on 7 July 2013 (don't pay any attention to date

pre-receive hook on server-side that refuse any push to master which has any non-linear history

故事扮演 提交于 2019-11-29 05:07:27
I am looking for a shell script ( sh , not bash possibly) that would refuse any push to master which has any non-linear history. I tried script from: How to avoid "Merge branch 'master' of ssh://gdcm.git.sourceforge.net/gitroot/gdcm/gdcm" which is implemented in ruby , but it does not even run on sourceforge server. I tried then the bash equivalent: https://fedorahosted.org/fedora-infrastructure/attachment/ticket/1342/pre-receive this one runs, but does not do what it is supposed to do (it does not reject anything). Thanks for suggestions. You can do this much, much more simply than your hook.