Tag Info

New answers tagged

2

The shell is likely waiting for the cmd.exe to complete. The /k option makes the command shell to stay open after the command passed on the command line completes. The FreeSSHd process spawns the cmd.exe process and is likely waiting for it to complete before continuing.


1

(answering for bash) No. The shell processes redirections first, which then truncates the file. Only then does cat start, and it's operating with an empty file. There is a tool called sponge in the moreutils package that lets you do this: cat somefile.txt | sort | uniq | sponge somefile.txt This command can be simplified (remove UUOC): sort -u ...


0

Similar to exebook, here's a C# implementation to get the target filename from a sourcefile. I found 1 small error in dbenham's examples: ren *_* *_NEW.* abc_newt_1.dat -> abc_newt_NEW.txt (should be: abd_newt_NEW.dat) Here's the code: /// <summary> /// Returns a filename based on the sourcefile and the targetMask, as used in ...


3

That's caused by the ignorespace value in $HISTCONTROL. From man bash: HISTCONTROL A colon-separated list of values controlling how commands are saved on the history list. If the list of values includes ignorespace, lines which begin with a space character are not saved in the history list. It could be caused by the HISTIGNORE ...


1

Your "echo" stands outside of for / do - loop that is why it will be printed only once. Put it INTO the do section like this: for /f "delims=" %%s in ('dir /b /a-d /o:gen') do ( if /i "%%~xs" equ "!suffix!" ( set /a num+=1 ) else ( if !num! neq 0 echo "!suffix!" !num! set num=1 set suffix=%%~xs ) echo "%suffix%" ...


1

If your batch file is called winrm.bat and you call (with or without call command) winrm ... probably you have your batch file calling himself. The easiest solution is to change the batch file name


2

Normally, sed processes each line (doing substitutions etc), then prints the result. If the processing involves the line being printed (e.g. sed's p command), then it gets printed twice (once during processing, then again by the automatic post-processing print). The -n option disables the automatic printing, which means the lines you don't specifically tell ...


0

Create a global macro in Word 2013: ' The Word macro for exporting to PDF (the Word window closes after finishing) Sub ExportToPDFext() ChangeFileOpenDirectory ThisDocument.Path ActiveDocument.ExportAsFixedFormat _ OutputFileName:=Left(ActiveDocument.FullName, InStrRev(ActiveDocument.FullName, ".")) + "pdf", _ ...


2

$ cat decode_mailto #!/bin/bash perl -lpe 's/%([0-9a-fA-F]{2})/chr(hex($1))/eg;s/mailto:/To: /g;s/subject=/Subject: /g;s/body=/\n/g;s/[&?]/\n/g' $ chmod 755 decode_mailto $ echo 'mailto:a@b.c?subject=qqq&body=www%20eee&' | ./decode_mailto To: a@b.c Subject: qqq www eee $


3

That looks like a mistake in some other script / batch command where a literal %PATH% was appended to the PATH instead of the contents of the PATH environment variable. This would have happened if the PATH wasn’t already set when the script set the PATH environment variable. If an environment variable isn’t actually set, %PATH% expands to a literal %PATH%. ...


0

Please test it with a dummy dataset before trying it out on the actual folder you wish to delete (I've tested but you can confirm at your end as well) @echo off setlocal EnableDelayedExpansion set adobe=adobe cc.msi echo %adobe% pause FOR /R M:\windows\ccmcache %%G IN ("*") DO ( set trgt=%%~nG%%~xG IF /I "!trgt!"=="%adobe%" RMDIR /S /Q %%~pG ) pause


0

The OpenSSH toolset does not understand .ppk key file format. It uses it's own format. Just as PuTTY (and WinSCP) uses it's format (the .ppk) and do does not understand the OpenSSH format. You can use PuTTYgen (from PuTTY toolset) to convert .ppk key to OpenSSH format. http://tartarus.org/~simon/putty-snapshots/htmldoc/Chapter8.html#puttygen-conversions


1

This is an expansion to @m0nhawk's answer In PowerShell you could do $date = wmic os get lastbootuptime | Select-String "\d\S+" | % { $_.Matches } | % { $_.Value } [Management.ManagementDateTimeConverter]::ToDateTime($date) Ridiculous how much code is needed for such a simple task


0

Using %h instead %p has already been suggested in another answer, but I'd like to add some improvements to make your code more robust. If, for instance, a matching directory contains a newline character in its name, you will in the best-case end up missing directories and getting some error messages from cp. At worst, you might override files anywhere on ...


0

Found this as have hit a similar need. With a new enough version of rsync, that's your best bet. If you don't have a recent version of rsync, then this does the trick: find path/to/source -type -d -exec mkdir path/to/dest/'{}' \; -exec chown --reference='{}' path/to/dest/'{}' \; -exec chmod --reference='{}' path/to/dest/'{}' \; (A variant of this can be ...


0

I think you are almost there. You can replace %p with %h in the -printf expression : %h : Leading directories of file's name (all but the last element). If the file name contains no slashes (since it is in the current directory) the %h specifier expands to ".". so the command would be something like : find "$dir" -name Sample.doc -printf "%h\n" | ...


0

The dirname command removes the filename from the full path


0

You can also try doing: brew uninstall ghostscript brew install ghostscript That fixed it for me.


0

The background is stored in the registry. There are a few different ways to set it. But there several ways to set a registry value via the command line. To set the background to a specific color you need to unset any wallpaers, and set the color. HKEY_CURRENT_USER\Control Panel\Colors\Background = 'r g b' HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper ...


0

I do not think this is an option, but you can easily change the background color by right clicking the desktop, choosing "Personalization", choosing "Desktop Background", and choosing "solid colors". Alternatively, you can make a 1px x 1px image of the color you want, and set as a tiled background image.


1

When you place the &, you're telling the shell to run what precedes it in the background and continue with a new command. When you put it at the end of the line, there's no command after so the shell returns to interactive mode. When you place it in the middle, the shell interprets the rest of the line as a new command. That command redirects the ...


0

reg export Hkey_local_Machine\Software\mcafee\key C:\export.txt && type C:\export.txt | findstr /i "key"


0

Well basically, when you run a command with & after it, you are loosing some functionality. Take this as an example, make a script that does nothing but returning 2 for example. run the script normally, issue echo $? and you will see the output 2. run the script with & after it, run echo $? and you will see the output 0. Also, when running nohup ...


0

To disable the effects sc stop uxsms To enable the effects sc stop uxsms You have to run it as Admin, you can create a batch scrip to do this, This topic is discussed in detail from the below forum, give a try on it. http://stackoverflow.com/questions/20516428/how-could-i-disable-windows-effects-through-batch


0

$ file access-client-win32.exe access-client-win32.exe: PE32 executable for MS Windows (console) Intel 80386 32-bit $ file access-client-win64.exe access-client-win64.exe: PE32+ executable for MS Windows (console) Mono/.Net assembly win32.exe -> PE32 win64.exe -> PE32+ ps: PE -> Portable Executable


0

For those of you wondering, I was able to fix it using Bob's PATH suggestion. I appended the following to my PATH: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\


0

"No longer recognises"? What happens when you try? What's the output? I suspect your PATH environment variable got changed (side note: this is why I always either refuse to make these changes or do it in a VM). Open the environment variable editor (search environment variable in the start menu, select the "edit the system env...", click the Environment ...


1

This issue has actually been discussed in a number of previous SU questions and answers, such as these and others: creating-an-elevated-shortcut-allowing-uac-to-be-bypassed-for-certain-trusted how-to-run-program-from-command-line-with-elevated-rights is-there-any-sudo-command-for-windows prevent-elevation-uac-for-an-application-that-doesnt-need-it ...


0

This prompt can be ignored by two methods, but reducing UAC sensitivity only. Try this methods and check you outcome. Select the "Change when these notifications appear" link at the bottom of the "Do you want to allow the following program from an unknown publisher to make changes on this computer" window. This way the 'UAC' reduces the sensitivity of the ...


1

It is not a script, per se, but rather a module. The module source is linked at the top of the page (the Source link). You need to save the module to your system to use it. After that you write your own script that imports this module and then you can use the functions from the module in your script. The page has a sample script that uses the module. ...


1

Personally, I'd refactor that a bit for readability (still relying on GNU date) function countdown(){ local now=$(date +%s) local end=$((now + $1)) while (( now < end )); do printf "%s\r" "$(date -u -d @$((end - now)) +%T)" sleep 0.25 now=$(date +%s) done echo } Mapping the date calls to OSX's BSD ...


3

One other way to do this is to use the following command-line that works both in Windows XP and Windows 7: net statistics workstation It has the advantage of being faster than the systeminfo alternative while formatting the date (which wmic does not). You also get a few other informations that can be useful if you are actually using this command for ...


0

Reference SCHTASKS - Create, delete, edit, list, start or stop a scheduled task. The task can be created on the local or a remote computer. The above link lists all of the possible options for schtasks. Is there a way to schedule a task (.bat) through the command line that runs every 5 minutes daily? You can do this with the following command: ...


0

What's under /etc/init.d will run when the system starts. Scripts placed under /home/pi/.config will only run when user pi logs in. /etc/init.d is generally used to start daemons, and I don't generally autologin. The way I'd do it is that I'd write the script and put it in my own script folder. Then I'd add to /etc/rc.local a line that calls my script. ...


1

Got it done seems the problem was a mistyped word.... no wonder it did not work missed a letter from a word lol


0

You have to use schtasks.exe - is part of the OS. Here are a lot of examples by microsoft. Here is the reference.


1

ping does not use a proxy. ping is sending ICMP packets directly to the target. A (web/http) proxy in contrast is used for TCP connections. Which programs use a proxy strongly depends on the developers. IE uses the IE proxy settings. Other browsers might at their first start query the IE proxy settings and suggest them as defaults to the user. Other ...


0

If you have access to another account on the domain you want to query against, run the command as that account. Here are some ways to do this: Use remote desktop to get to a computer in the domain Use the Windows runas command-line command in front of your net user command Shift + right-click Command Prompt and select *Run as different user`


1

You will need to make sure to run as administrator, otherwise you will not actually have the permissions required to modify the registry. If you're running the commands manually from a command prompt with elevated permissions you'll notice the commands worked fine but once you try to click on the batch files from windows explorer or automate them (without ...


0

The rm command doesn't work since your filename includes white spaces, so for this reason you either have to quote your file, or you can use backslash without quoting, like that: rm ./Career/No\ Longer\ Needed/Microsoft\ Resume\ 2004.doc So, you cannot really print the path and delete it by copy pasting because you either need to add quotes or ...


0

find have an -exec argument. If you are trying to delete find output, just use this command: find -iname "*Resume 2004*doc~" -exec rm -f {} \;


1

HowToGeek demonstrates a Windows PowerShell script that works very well at How To Send Email From the Command Line in Windows Without Extra Software Here is the method: First you're defining the variables: $EmailFrom = “yourMail@gmail.com” $EmailTo = “theRecipient'sAddress@someServer.com” $Subject = “your subject” $Body = “some text” $SMTPServer ...


0

Your goal is well formulated, so why don't you transform it to batch commands? @ECHO OFF >NUL @SETLOCAL enableextensions enabledelayedexpansion rem For all files with DSW xtension FOR %%f IN (*VU*.dsw) DO ( rem get my filename: no path, no file extension set "filename=%%~nf" rem initialize variables set "variable1=var1" set "variable2=var2" ...


0

Even various linux versions aren't compatible with one another. For example, you could install a program on it with e.g. apt-get and one distribution of linux gets the program from one depository, another gets it from another depository, as it should, but there could be differences in the programs. A program like ssh might store configuration files in ...


1

Linux ifconfig translates (loosely) to the ipconfig command in windows. In a Cygwin-inside-Windows, you have access the full range of windows programs including any batch files and additional user added programs that are along the PATH= Try "ipconfig.exe /all" which is the c:\windows\system32\ipconfig.exe program. Which is actually at ...


0

Besides F7, to print the command history of current session, run: DOSKEY /history


1

HowToGeek demonstrates a Windows PowerShell script that works very well at How To Send Email From the Command Line in Windows Without Extra Software Here is the method: First you're defining the variables: $EmailFrom = “yourMail@gmail.com” $EmailTo = “theRecipient'sAddress@someServer.com” $Subject = “your subject” $Body = “some text” $SMTPServer ...


0

I will try to elaborate on @Philippe answer: The command: vboxmanage startvm <machine_name> will start the server which name is "machine_name". For example if you have a machine that called UbuntuServer then the command will look like so: vboxmanage startvm UbuntuServer Note vboxmanage should be in you path to run this command. Add if to your path if ...


0

A procedure :unique returns a temporary file name from momentary date and time. The precision of time is approximately 3 milliseconds, collision probability very close to zero. @echo off set "somefile=" call :unique somefile rem echo %somefile% type file.txt file2.txt 2>NUL | sort > "%tmp%\%somefile%.txt" someprog "%tmp%\%somefile%.txt" erase ...


0

If you don't mind having a cmd window open all the time: @echo off :nope shutdown /a goto :nope (put in a .bat file). Or another trick: always have a unsaved word document open with some text in it. windows will ask if you want to force shutdown. click cancel and you can go on If nothing else helps and you are a administrator on your PC then try this: ...



Top 50 recent answers are included