scripting

How do I run a java program from a different directory?

爱⌒轻易说出口 提交于 2019-12-17 18:28:59
问题 I have a java program that I would like to be able to run from anywhere on my machine. I would like to run it from my Cygwin command prompt. I've made scripts to call the java program. I added the location of the java program to the classpath, and the scripts work when I run them from the java program's directory. However, when I try to run from any other directory, I get: java.lang.NoClassDefFoundError: commandprogram/CommandProgram This is my script: #!/bin/sh CWD=`dirname "$0"` java -cp "

How to get PID of process just started from within a batch file?

纵饮孤独 提交于 2019-12-17 18:26:36
问题 In Windows batch scripting there is start command which starts a new process. Is it possible to get PID of the process just started? 回答1: You can in batch but not directly per say. You need to either parse the output of tasklist.exe or use wmic.exe. Both require you to know what you just started which of course you will. Using tasklist.exe: for /F "TOKENS=1,2,*" %a in ('tasklist /FI "IMAGENAME eq powershell.exe"') do set MyPID=%b echo %MyPID% To use this in a batch script double up the

source all files in a directory from .bash_profile

本秂侑毒 提交于 2019-12-17 18:03:52
问题 I need to allow several applications to append to a system variable ($PYTHONPATH in this case). I'm thinking of designating a directory where each app can add a module (e.g. .bash_profile_modulename). Tried something like this in ~/.bash_profile: find /home/mike/ -name ".bash_profile_*" | while read FILE; do source "$FILE" done; but it doesn't appear to work. 回答1: Wouldn't for f in ~/.bash_profile_*; do source $f; done be sufficient? Edit : Extra layer of ls ~/.bash_* simplified to direct

Shell script to get the process ID on Linux [duplicate]

不羁的心 提交于 2019-12-17 17:42:28
问题 This question already has answers here : How to get pid given the process name (4 answers) Closed 2 years ago . I want to write a shell script ( .sh file) to get a given process id. What I'm trying to do here is once I get the process ID, I want to kill that process. I'm running on Ubuntu (Linux). I was able to do it with a command like ps -aux|grep ruby kill -9 <pid> but I'm not sure how to do it through a shell script. 回答1: Using grep on the results of ps is a bad idea in a script, since

Basic Dual Contouring Theory

扶醉桌前 提交于 2019-12-17 17:36:07
问题 I've been searching on google, but cannot find anything basic. In it's most basic form, how is dual contouring (for a voxel terrain) implememted? I know what it does, and why, but cannot understand how to do it. JS or C# (preferably) is good.Has anyone used Dual contouring before and can explain it briefly? 回答1: Ok. So I got bored tonight and decided to give implementing dual contouring myself a shot. Like I said in the comments, all the relevant material is in section 2 of the following

Javascript engine can not be found - scripting for the Java platform

ぐ巨炮叔叔 提交于 2019-12-17 17:28:06
问题 Recently some of my users have been reporting problems with NullPointers. Thanks to one of them, I have managed to find out that my application can't find the Javascript engine that should theoretically come with the JRE (most of them have the JDK anyway). How can they manually install the scripting engine? Thanks in advance... P.S. Most of these people have OpenJDK. However, this doesn't happen to me (I am also an OpenJDK user)... EDIT: They have at least version 1.5, most of them have 1.6.

Simple background process question in bash

怎甘沉沦 提交于 2019-12-17 16:54:19
问题 I am using BASH and I am calling a couple of functions which update a couple of variables. These functions take too long to complete so I was thinking running all of the functions in the background so that they can be running simultaneously. This is a basic example of what i am asking. #/bin/bash func1() { var1="one" } func2() { var2="two" } func3() { var3="three" } echo "Right now this is what i am doing" func1 & func2 & func3 & wait echo "The variables are $var1 $var2 $var3" echo "But the

Sub-shell differences between bash and ksh

自作多情 提交于 2019-12-17 16:48:34
问题 I always believed that a sub-shell was not a child process, but another shell environment in the same process. I use a basic set of built-ins: (echo "Hello";read) On another terminal: ps -t pts/0 PID TTY TIME CMD 20104 pts/0 00:00:00 ksh So, no child process in kornShell (ksh). Enter bash, it appears to behave differently, given the same command: PID TTY TIME CMD 3458 pts/0 00:00:00 bash 20067 pts/0 00:00:00 bash So, a child process in bash. From reading the man pages for bash, it is obvious

Check the open FD limit for a given process in Linux

孤街醉人 提交于 2019-12-17 15:26:45
问题 I recently had a Linux process which "leaked" file descriptors: It opened them and didn't properly close some of them. If I had monitored this, I could tell - in advance - that the process was reaching its limit. Is there a nice, Bash\Python way to check the FD usage ratio for a given process in a Ubuntu Linux system? EDIT: I now know how to check how many open file descriptors are there; I only need to know how many file descriptors are allowed for a process . Some systems (like Amazon EC2)

Hiding user input on terminal in Linux script

泪湿孤枕 提交于 2019-12-17 15:26:06
问题 I have bash script like the following: #!/bin/bash echo "Please enter your username"; read username; echo "Please enter your password"; read password; I want that when the user types the password on the terminal, it should not be displayed (or something like *******) should be displayed). How do I achieve this? 回答1: Just supply -s to your read call like so: $ read -s PASSWORD $ echo $PASSWORD 回答2: Update In case you want to get fancy by outputting an * for each character they type, you can do