New answers tagged

3

The Set-Alias command does not support adding parameters to your command as PowerShell will interpret that as parameters for the Set-Alias rather than parsing them through as the alias. Instead, you need to create a function, call the new command from there, and use Set-Alias to give that function a new name. For example: PS> Function remove-...


3

The comparison is fine, the problem is that you're missing the variable to compare against. Because your entire SSH command line is inside double quotes, the $5 is eaten by your local shell before it even gets to 'ssh' – you must type it as \$5 to avoid that. Same goes for the $0 later (notice how the error message says "print bash;" in its place).


0

But whatever I try to start wsl.exe from within my Tcl scripts, using the (Expect-) 'spawn' command or even simply: exec C:\Windows\system32\wsl.exe $lnxcmd $params , I get either 'file not found' for wsl.exe or no response at all. Maybe your path is wrong, I don't use Tcl/tk but from what I can read here : https://www.tcl.tk/man/tcl8.3/TclCmd/...


0

Half of the script is unnecessary. Remove all checks for time. Just set it to check for name and delete. Then set it in the crontab on each minute. If you want to stop it for some reason, just stop the cron by commenting the execution line and restart the cron


0

Well, I found the problem with terminating. I had to login to the particular node that was executing that script, to then execute kill. I still am not sure how to avoid this in the future.


2

See the Set DEBUG=echo line? Disable this line with REM or :: when you are sure that it is doing what you want it to do. This script is harmless while it exists.. not so much if you remove it. The if /i not "%DownloadsDir%" == "%CD%" line comes from being stupid and blowing away all of my files in the wrong directory when I was younger and dumber. Also....


0

With Powershell 5.1: $extensions_list = Get-ChildItem -Path 'C:\folder_path\' -Recurse foreach ( $extension in $extensions_list) { if ($extension.Attributes -notlike "Directory") { Remove-Item $extension.FullName } } It's removes all itens that are not Directory. $extension.FullName = Item Path $extension.Attributes = Item Type ( ...


1

I agree with other comments. You would need a second machine running a connectivity test or something of the sort to the machine that is running the other code to detect a failure. Here is a sample powershell script that would email you if it did not get a successful ping response back from the other machine. Following code assumes you use 0ffice365 mail/...


1

I agree with Worthwelle. There would need to be another machine monitoring the status of the machine where that script was being run. In this case, if there was a machine that was reliable enough to monitor the first machine, then you might as well just run the script on that machine instead. Best solution... correct the issue causing machine running the ...


3

It seems python outputs its version to stderr, not stdout. So, redirect stderr to stdout in order to capture it pythonVer=$(ssh "$user"@"$ip" 'python --version 2>&1') or pythonVer=$(ssh "$user"@"$ip" 'python --version' 2>&1)


0

The answer from xenoid made me research a little bit about imagemagick (which I didn't know beforehand). After some trial and error I got the (at least for me) optimum process. First of all we convert our image into grayscale with a threshold of 40% convert input_image.jpg -colorspace gray -auto-level -threshold 40% output_image.jpg Then, If there are ...


1

With ImageMagick: In-place version: [magick] mogrify -level 20%,80% yourfile.jpg New file version: [magick] convert input.jpg -level 20%,80% output.jpg Where 20% and 80% are the luminosity under/over which everything becomes pure black/white. Depending on version used, commands are mogrify and convert (old version) or magick mogrify and magick convert (...


0

For posterity, I hit this on my Mac after renaming a shell file in Finder that was open in BBEdit. Then, when I modified the file in BBEdit (which correctly reflected the new filename) and saved, I could no longer run the script. For me, the fix was as simple as quitting BBEdit and re-launching, then saving the file once more. 🤷‍♂️ My issue was happening ...


0

Check out RunJS I recently have started using RunJS on my mac - it is such a great tool and helps me immensely to test out things quickly. RunJS is available for the Windows machine as well. You can find download link here


0

No matter I tried I couldn't reliably change wallpaper with regedit and UpdatePerUserSystemParameters (even with large loops), so I ended up using powershell, it works every time. See https://www.joseespitia.com/2017/09/15/set-wallpaper-powershell-function/ Set-Wallpaper.ps1: # use powershell.exe Set-Wallpaper.ps1 -Image "<path to image>" param ([...


Top 50 recent answers are included