scripting

standard in must be a tty Python script removing Sudo

元气小坏坏 提交于 2020-01-07 02:56:25
问题 I am trying to run the command "sudo service awslogs start" from a python script. I cannot use 'sudo' so I change the command to "su -c 'service awslogs start'" but that does not seem to work either. I still get the error su: user if=/dev/null does not exist or standard in must be a tty Any ideas as to how to fix this? 回答1: sudo -S reads from stdin, see man sudo : -S, --stdin Write the prompt to the standard error and read the password from the standard input instead of using the terminal

MacRuby custom initializers

空扰寡人 提交于 2020-01-06 15:31:50
问题 Just discovered MacRuby this afternoon; man is that ever COOL! However, I've run into some difficulties while attempting to extend an old project with some MacRuby-fu. Here's the deal: So I have a superclass in Objective-C that looks like this: @implementation Foo - (id) init { if (self = [super init]) { //Do nothing, don't have enough data... } return self; } - (id) initWithName:(NSString*)n andLocation:(NSString*)loc andSomethingElse:(Bar*)b { if (self = [super init]) { //Set a LOT of

Python Login Script; multiple passwords per account

亡梦爱人 提交于 2020-01-06 14:42:07
问题 I've asked a question similar and can be found here: Python Login Script; Usernames and Passwords in a separate file However, I'm now looking to extend the script so that it can look at multiple passwords per user account in the text file and know that the first password is the legitimate password while any other specified password linked to that account will throw up an error message. So right now the external username file is set up so that its: Admin:AdminPW Now I'm looking to extend it to

SAP Script Runs Slower Over Time VBA

三世轮回 提交于 2020-01-06 08:05:42
问题 When I run a SAP script in VBA (excel) over a long period of time, the SAP session starts to slow down. If I interrupt the code and start it again, the SAP session still runs at the slow speed it was at. If I close excel and run the code again, the SAP session still runs at the slow speed. However, if I close the SAP session and reopen it and then run the code (not closing excel), the speed goes back to optimal speed again. I ran the below code (as a test) to see the speed decrease. When the

PowerShell: CLI or GUI - which do you need or prefer? [closed]

别等时光非礼了梦想. 提交于 2020-01-06 07:55:54
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . PowerShell v1.0 is obviously a console based administrative shell. It doesn't really require a GUI interface. If one is required, like

Calculate size of iOS framework using Swift script

雨燕双飞 提交于 2020-01-06 07:01:38
问题 I have a Swift script I'm writing to calculate the file size of an iOS framework. However, I have weird results. In one framework I have this file structure as shown in the Finder: /{FrameworkName}.framework/Modules/{FrameworkName}.swiftmodule/ /{FrameworkName}.framework/Modules/{FrameworkName}.swiftmodule/x86_64.swiftmodule /{FrameworkName}.framework/Modules/{FrameworkName}.swiftmodule/x86_64.swiftdoc HOWEVER! If I run code to calculate file size in my Swift script, as I'm looping through

Tools to reduce generated HTML size

柔情痞子 提交于 2020-01-06 07:00:27
问题 I'm using google docs, and some templates we are using were created using MS-Office. The resulting HTML is fat and ugly, and the 500KB per doc limitation on google makes some cleanup mandatory. I was able to find redundant "style" attributes and move them to some CSS class, and rename the most redundant classes names to shorter ones, which makes me save about 50% of the original size. Are you aware of some existing tools/scripts/lib which could do this painful job for me, or at least help me

Batch - syntax error when trying to echo greater-then sign (>)

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-06 06:05:35
问题 I have the following stript: @ECHO OFF SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION SET /A countArgs=1 ... SET /A countArgs+=1 CALL :error "!countArgs!. Argument ^-^> bla" EXIT /B 1 ... :error ECHO ERROR ECHO %~1 EXIT /B 0 But the 2. ECHO -line in the :error routine echo s nothing. When I reduce the CALL argument string to "!countArgs!. Argument ^-^>" i get a syntax error and when i reduce it to "!countArgs!. Argument ^-" or even "!countArgs!. Argument -" it works properly. According to

Modifying PowerShell to display phone number in International format without changing the AD Attributes?

只愿长相守 提交于 2020-01-06 06:01:33
问题 I need to modify the below code with some International Phone area code formatting from the Active Directory without modifying the actual AD attribute value: $defaultTelephone = '1800 552 001' #Get Active Directory information for the currently logged on user $sysInfo = New-Object -ComObject 'ADSystemInfo' $userDN = $sysInfo.GetType().InvokeMember('UserName', 'GetProperty', $null, $sysInfo, $null) $adUser = [ADSI]"LDAP://$($userDN)" [void][Runtime.InteropServices.Marshal]: