scripting

Returning array from javascript class method to a script

你。 提交于 2019-12-30 11:33:09
问题 I'm building a javascript application using object oriented techniques and I'm running into a problem that I hope someone here can help me resolve. The following method is designed to return an array populated with rows of data from a web SQL database: retrieveAllStoreSearches : function(){ this.db.transaction( function(transaction){ transaction.executeSql( "SELECT name,store,address FROM searchResults ORDER BY name ASC", [], function(transaction, results){ var returnArr = []; for(var i = 0;

How can I capitalize the first letter of each word?

亡梦爱人 提交于 2019-12-30 11:30:11
问题 I need a script in any language to capitalize the first letter of every word in a file. Thanks for all the answers. Stackoverflow rocks! 回答1: In Python, open('file.txt').read().title() should suffice. 回答2: Using the non-standard (Gnu extension) sed utility from the command line: sed -i '' -r 's/\b(.)/\U\1/g' file.txt Get rid of the " -i " if you don't want it to modify the file in-place. note that you should not use this in portable scripts 回答3: C#: string foo = "bar baz"; foo = System

How can I have a PHP script run a shell script as root?

扶醉桌前 提交于 2019-12-30 11:14:16
问题 Running Fedora 9/10, Apache 2, PHP 5... Can I run a shell script as root, from a PHP script using exec()? Do I just give Apache root priveleges, and then add "sudo" in front of them command? Specifically, I'm trying to start and stop a background script. Currently I have a shell script that just runs the app, start.sh: #!/bin/bash /path/to/my/app/appname And a script that kills the app, stop.sh: #!/bin/bash killall appname Would I just do: <?php exec("sudo start.sh"); ?> Thanks in advance.

write a batch file to remove the folders by date and time wise

南笙酒味 提交于 2019-12-30 11:01:09
问题 Exact Duplicates: How to write a batch file to delete the files which are 5 days or older from a folder? write a batch file to delete 6 days older files from a folder write a batch file to delete 5 daya older files from a folder How do I write a batch file to delete folders and files on a time basis? How do I create a batch script that will delete a folder on a scheduled basis? write a script to delete files from a folder which are 5 days older than current date I have a folder named 'dump'

Update Explorer configuration without restarting it

走远了吗. 提交于 2019-12-30 10:48:08
问题 I am wondering is there a way to refresh the HKLM registry key HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer - without restarting the shell. I would like to be able to do this without restarting explorer. Is there any known way to do that ? So far, I found only this thing: RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True which doesn't work for my case. It looks insane to me that MS made Explorer so it can't re-read its configuration while running) but you

Error “The object invoked has disconnected from its clients” - automate IE 8 with python and win32com

微笑、不失礼 提交于 2019-12-30 08:18:09
问题 I would like to automate Internet Explorer 8 (using python 2.7 on Windows 7) machine. Here is my code after a post found on SO: import sys, time from win32com.client import WithEvents, Dispatch import pythoncom import threading stopEvent=threading.Event() class EventSink(object): def OnNavigateComplete2(self,*args): print "complete",args stopEvent.set() def waitUntilReady(ie): if ie.ReadyState!=4: while 1: print "waiting" pythoncom.PumpWaitingMessages() stopEvent.wait(.2) if stopEvent.isSet()

Create DB in SQL Server based on Visio Data Model

烂漫一生 提交于 2019-12-30 07:43:08
问题 I have created a database model in Visio Professional (2003). I know that the Enterprise version has the ability to create a DB in SQL Server based on the data in Visio. I do not have the option to install Enterprise. Aside from going through the entire thing one table and relationship at a time and creating the whole database from scratch, by hand, can anyone recommend any tool/utility/method for converting the visio database model into a SQL Script that can be used to create a new DB in SQL

Redirect output from a command within a batch file whose output is already redirected?

邮差的信 提交于 2019-12-30 07:13:34
问题 I've searched high and low, but all the suggestions and tips I've found do not work for some reason. I have a batch file that is being invoked as such: cmd /C "automateMyProgram.bat >> automation.log 2>>&1" That works great: automation.log gets loaded with all the stdout and stderr for that particular batch file. However, within that batch script I have the following command: start php updateDB.php param1 param2 ^> updateDB.log The php script does get executed just fine and reads in the

How to check if a files exists in a specific directory in a bash script?

淺唱寂寞╮ 提交于 2019-12-30 04:59:05
问题 This is what I have been trying and it is unsuccessful. If I wanted to check if a file exists in the ~/.example directory FILE=$1 if [ -e $FILE ~/.example ]; then echo "File exists" else echo "File does not exist" fi 回答1: You can use $FILE to concatenate with the directory to make the full path as below. FILE="$1" if [ -e ~/.myexample/"$FILE" ]; then echo "File exists" else echo "File does not exist" fi 回答2: This should do: FILE=$1 if [[ -e ~/.example/$FILE && ! -L ~/example/$FILE ]]; then

Traversing a multi-dimensional hash in Perl

百般思念 提交于 2019-12-30 04:57:06
问题 If you have a hash (or reference to a hash) in perl with many dimensions and you want to iterate across all values, what's the best way to do it. In other words, if we have $f->{$x}{$y}, I want something like foreach ($x, $y) (deep_keys %{$f}) { } instead of foreach $x (keys %f) { foreach $y (keys %{$f->{$x}) { } } 回答1: Here's an option. This works for arbitrarily deep hashes: sub deep_keys_foreach { my ($hashref, $code, $args) = @_; while (my ($k, $v) = each(%$hashref)) { my @newargs =