scripting

Fastest way to generate 11,000,000 unique ids

蹲街弑〆低调 提交于 2019-12-22 15:13:14
问题 I am trying to create php script that generates 11,000,000 million unique ids in sequential order. However, I am trying to do it very quickly within 20 min it should generate these 11 million unique ids. Also, once it reaches 12,000,000 it should wrap around and start back at zero. Here is what I have so far. This script would would only return one id at a time. I just added a loop to see how long it would take to generate the ids. while(true){ try { $this->getAdapter()->query('INSERT INTO

AppleScript that reads active application name, title and URL

青春壹個敷衍的年華 提交于 2019-12-22 14:04:33
问题 I need AppleScript that, when lunched from command line, will return three things: current active application name; ex. "Google Chrome", "Safari", "Steam", "iTunes", "Atom" ect. current active application title, if there is one if current active application is a browser, I want the current active tab URL examples: Google Chrome; AppleScript: How to get URL of Safari tab which failed to load? - Stack Overflow; https://stackoverflow.com/ iTunes; iTunes iTerm2; 1. node test.js (sleep) Safari,

detect if something is modified in directory, and if so, backup - otherwise do nothing

跟風遠走 提交于 2019-12-22 12:39:31
问题 I have a "Data" directory, that I rsync to a remote NAS periodically via a shell script. However, I'd like to make this more efficient. I'd like to detect if something has changed in "Data" before running rsync. This is so that I don't wake up the drives on the NAS unnecessarily. I was thinking of modifying the shell script to get the latest modified time of the files in Data (by using a recursive find), and write that to a file every time Data is rsynced. Before every sync, the shell script

How to extract from a file text between tokens using bash scripts

纵然是瞬间 提交于 2019-12-22 12:36:35
问题 I was reading this question: Extract lines between 2 tokens in a text file using bash because I have a very similar problem... I have to extract (and save it to $variable before printing) text in this xml file: <--more labels up this line> <ExtraDataItem name="GUI/LastVMSelected" value="14cd3204-4774-46b8-be89-cc834efcba89"/> <--more labels and text down this line--> I only need to get the value= (obviously without brackets and no 'value='), but first, I think it have to search "GUI

Linux cronjob doesn't work (execute script)

雨燕双飞 提交于 2019-12-22 11:03:52
问题 I created a cronjob with the command crontab -e: */1 * * * * /var/lib/tomcat/webapps/ROOT/WEB-INF/scripts/test.sh This file test.sh should be executed every minute. But it doesn't work. If I run the script manually it works fine. So I think the problem is the cronjob not the script ;) Are there any permissions or something else which block the cronjob? Is the cronjob syntax correct? Thx 回答1: For a start, you don't need the /1 if you want it done every minute. Just setting the minute field to

Linux cronjob doesn't work (execute script)

╄→гoц情女王★ 提交于 2019-12-22 11:02:05
问题 I created a cronjob with the command crontab -e: */1 * * * * /var/lib/tomcat/webapps/ROOT/WEB-INF/scripts/test.sh This file test.sh should be executed every minute. But it doesn't work. If I run the script manually it works fine. So I think the problem is the cronjob not the script ;) Are there any permissions or something else which block the cronjob? Is the cronjob syntax correct? Thx 回答1: For a start, you don't need the /1 if you want it done every minute. Just setting the minute field to

Creating shortcut links (.lnk) from Java

孤街浪徒 提交于 2019-12-22 11:01:38
问题 I am writing an installer (launcher) in Java and require the ability to be able to create a shortcut on the users desktop during the process. I am interested in any ideas as the best way to do this. My one option I have considered is using a VB Script on windows and using the native 'shortcut.exe' to do it for me, however a third party file utility would be preferred. 回答1: /** * Create an Internet shortcut * @param name name of the shortcut * @param where location of the shortcut * @param

how to convert a text/plain to text/x.shellscript

家住魔仙堡 提交于 2019-12-22 10:42:31
问题 I am sending a .sh file created from a windows machine to a linux so that I could run it there. The problem is that I keep on getting an error called bad interpreter.But when I program the shell script in the linux machine it runs with no problems even though it has the same code with the one sent from the windows machine. After my ivestigation, I found out that the windows machine .sh script is a text/plain file(using file -bi) and the other one from the linux machine is a text/x.shellscript

Avoid expansion of * in bash builtin function let

£可爱£侵袭症+ 提交于 2019-12-22 08:40:41
问题 I have a problem with a bash script. I have to use the operator * to multiplicate. Instead the script bugs me with expansion and using as operator the name of the script itself. I tried with single quotes but it doesn't work :( Here's the code #!/bin/bash -x # Bash script that calculates an arithmetic expression # NO PRECEDENCE FOR OPERATORS # Operators: + - * if [ "$#" -lt "3" ] then echo "Usage: ./calcola.scr <num> <op> <num> ..." exit 1 fi result=0 op=+ j=0 for i in "$@" do if [ "$j" -eq

How do I convert filenames from unicode to ascii

ぃ、小莉子 提交于 2019-12-22 08:32:57
问题 I have a bunch of music files on a NTFS partition mounted on linux that have filenames with unicode characters. I'm having trouble writing a script to rename the files so that all of the file names use only ASCII characters. I think that using the iconv command should work, but I'm having trouble escaping the characters for the 'mv' command. EDIT: It doesn't matter if there isn't a direct translieration for the unicode chars. I guess that i'll just replace those with a "?" character. 回答1: I