scripting

How can I make Windows software run as a different user within a script?

我与影子孤独终老i 提交于 2019-12-12 09:45:18
问题 I'm using a build script that calls Wise to create some install files. The problem is that the Wise license only allows it to be run under one particular user account, which is not the same account that my build script will run under. I know Windows has the runas command but this won't work for an automated script as there is no way to enter the password via the command line. 回答1: This might help: Why doesn't the RunAs program accept a password on the command line? 回答2: I recommend taking a

How can I make the batch file wait until another batch file completes execution?

≯℡__Kan透↙ 提交于 2019-12-12 09:29:01
问题 How can I make a batch file wait until another batch file has finished? For example, I have: echo hi >r.txt echo some piece of code >>r.txt start ar.bat echo some piece of code >>ar.txt I want the code after start ar.bat to execute only after ar.bat finishes executing. I tried without start and it works, but I want to run ar.bat in a separate window. Is there any method to check whether ar.bat has finished? 回答1: Use call ar.bat to do it completely with batch file commands. Use start /wait ar

How to be notified when a script's background job completes?

你离开我真会死。 提交于 2019-12-12 09:27:03
问题 My question is very similar to this one except that my background process was started from a script. I could be doing something wrong but when I try this simple example: #!/bin/bash set -mb # enable job control and notification sleep 5 & I never receive notification when the sleep background command finishes. However, if I execute the same directly in the terminal, $ set -mb $ sleep 5 & $ [1]+ Done sleep 5 I see the output that I expect. I'm using bash on cygwin. I'm guessing that it might

How to use input filename to generate output filename with Rake?

人走茶凉 提交于 2019-12-12 09:08:31
问题 I've got some input files which I want to encode using Ruby. The output from the encoding should match some pattern based on the filename of the input file. In order to not do this by hand, I want to use Rake as help for automation. Further I'd like to not specify a single task for every input file. I've tried some FileList "magic" but it didn't work out. Here's the code: desc 'Create all output from specified input' task :encode do FileList['input/*.txt'].each {|input| file "output/output_#

Binding on a port with netpipes/netcat

懵懂的女人 提交于 2019-12-12 08:58:24
问题 I am trying to write a simple bash script that is listening on a port and responding with a trivial HTTP response. My specific issue is that I am not sure if the port is available and in case of bind failure I fall back to next port until bind succeeds. So far to me the easiest way to achieve this was something like: for (( i=$PORT_BASE; i < $(($PORT_BASE+$PORT_RANGE)); i++ )) do if [ $DEBUG -eq 1 ] ; then echo trying to bind on $i fi /usr/bin/faucet $i --out --daemon echo test 2>/dev/null if

Difference between korn and bash shell [closed]

倾然丶 夕夏残阳落幕 提交于 2019-12-12 08:19:45
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I am completely new to Unix. Presently, I have been asked to learn about both KornShell (ksh) and Bash shell . Can some one please give me a short overview about the two? Is the term " shell " synonymous to " terminal "? I understand that I can read documents about both online. But I believe that an overview

How do I assign a null value to a variable in PowerShell?

自古美人都是妖i 提交于 2019-12-12 08:17:46
问题 I want to assign a null value to a variable called $dec , but it gives me errors. Here is my code: import-module activedirectory $domain = "domain.example.com" $dec = null Get-ADComputer -Filter {Description -eq $dec} 回答1: These are automatic variables, like $null , $true , $false etc. about_Automatic_Variables , see https://technet.microsoft.com/en-us/library/hh847768.aspx?f=255&MSPPError=-2147217396 $NULL $null is an automatic variable that contains a NULL or empty value. You can use this

Enable / disable wifi via bash scripting on Android

非 Y 不嫁゛ 提交于 2019-12-12 07:48:56
问题 I am trying to enable / disable the wifi device in my android device in a bash script. I am using the terminal emulator and the program Script Manager to execute bash scripts on the phone (which is a rooted Nexus One). The normal way to do this in linux would be something like ifconfig eth0 up That gives me "eth0: no such device" Trying iwconfig eth0 gives the same, and iwconfig gives a list of devices with no eth0 on it. Now if I turn on wifi (manually from the GUI) and type iwconfig it

How to get USB devices List from Browser

孤者浪人 提交于 2019-12-12 07:17:23
问题 What browser-based technology would allow me to query the client's currently connected USB devices - specifically name and device id of these. Of course, I'm ok with the client having to allow and confirm such an activity. I don't care if at low-level, it uses WMI, direct access or some other sort of access layer, all I want is to be able to use it from within a browser. I'd appreciate code samples and I'd be extra happy with a browser-independent solution. 回答1: You can't do that from a

Function to count number of lines in a text file

假如想象 提交于 2019-12-12 07:12:24
问题 Need a function that will accept a filename as parameter and then return the number of lines in that file. Should be take under 30 seconds to get the count of a 10 million line file. Currently have something along the lines of - but it is too slow with large files: Dim objFSO, strTextFile, strData, arrLines, LineCount CONST ForReading = 1 'name of the text file strTextFile = "sample.txt" 'Create a File System Object Set objFSO = CreateObject("Scripting.FileSystemObject") 'Open the text file -