command-prompt

Command prompt output being read as empty string

空扰寡人 提交于 2019-12-17 19:52:52
问题 I'm trying to execute command prompt commands and read the output in C#. This is my code: ProcessStartInfo cmdInfo = new ProcessStartInfo("cmd.exe", "/c " + command); cmdInfo.CreateNoWindow = true; cmdInfo.RedirectStandardOutput = true; cmdInfo.UseShellExecute = false; Process cmd = new Process(); cmd.StartInfo = cmdInfo; cmd.Start(); string result = cmd.StandardOutput.ReadToEnd(); cmd.WaitForExit(); cmd.Close(); return result; It works most of the time, but sometimes result="" when that's

Shell prompt that is based on location in filesystem

我们两清 提交于 2019-12-17 19:52:38
问题 I have to work within three main directories under the root filesystem - home/username, project, and scratch. I want my shell prompt to display which of these top level directories i am in. Here is what I am trying to do: top_level_dir () { if [[ "${PWD}" == *home* ]] then echo "home"; elif [[ "${PWD}" == *scratch* ]] then echo "scratch"; elif [[ "${PWD}" == *project* ]] then echo "project"; fi } Then, I export PS1 as: export PS1='$(top_level_dir) : ' Unfortunately this is not working as I

Is there a way to capture user input in maven and assign it to a maven property?

流过昼夜 提交于 2019-12-17 19:19:20
问题 Is there a way to pause the maven execution flow to provide a command prompt so user can input text. Then I would like the provided text to be stored in a maven properties. If the user input could be masked that would be a bonus. This would be really useful to avoid storing passwords in pom. Many Thanks 回答1: You can catch a user input using maven-antrun-plugin . The following example show how ask current user the new project version. <profile> <id>change-version</id> <build> <defaultGoal

How to copy files from folder tree dropping all the folders with Robocopy?

心已入冬 提交于 2019-12-17 18:15:04
问题 I have the following folder structure: FolderA --Folder1 --Folder2 --Folder3 ... --Folder99 Folders 1 through 99 have files in them. All I want to do is to copy ALL THE FILES into ONE FOLDER, basically do a FolderA copy, and wipe out Folders 1-99 keeping all the files. I'd like to do it with Robocopy from cmd.exe if possible (Windows Server 2008) 回答1: Why use robocopy ? It's a good tool for a specific task but this is not the one. You can simply use what cmd already gives you: for /r %f in (*

Server is already running in Rails

纵饮孤独 提交于 2019-12-17 15:02:42
问题 When I am starting rails server using rails s command it is showing A server is already running. Check C:/Sites/folder/Pids/Server.pids When I open the file it is outputting a 4 digit number only so how could I resolve this issue ? FYI No other instance of Rails cmd is running this time. Checked Task manager but only cmd.exe is showing no else process is running. (using Windows). 回答1: Remove the file: C:/Sites/folder/Pids/Server.pids Explanation In UNIX land at least we usually track the

How do I make a log of all ECHO commands in a BATCH file?

半世苍凉 提交于 2019-12-17 12:02:26
问题 I am trying to use a BATCH file as a choose your own adventure story in which the user can create a character and be called by name and such by the characters in the story. It hit me an hour back that it would be cool if as or after the BATCH file containing the story was run it made a log of all of the ECHO commands so that later the player could read what they did on any given play threw. I would like the log file to read like this: %date% %time% (all text displayed by echo commands for the

Modify cmd.exe properties using the command prompt

时间秒杀一切 提交于 2019-12-17 10:18:20
问题 Isn't that nicely recursive? I've got a portable command prompt on my external drive, and it has a nice .bat file to configure some initial settings, but I'd like more! Here's what I know how to set from .bat: Colors = (color XY) where x and y are hex digits for the predefined colors Prompt = (prompt $p$g) sets the prompt to "C:\etc\etc >" the default prompt Title = (title "text") sets the window title to "text" Screen Size = (mode con: cols=XX lines=YY) sets the columns and lines size of the

Start/Stop and Restart Jenkins service on Windows

做~自己de王妃 提交于 2019-12-17 10:12:29
问题 I have downloaded "jenkins-1.501.zip" from http://jenkins-ci.org/content/thank-you-downloading-windows-installer . I have extracted zip file and installed Jenkins on Windows 7 successfully. Jenkins runs at http://localhost:8080/ well. I want to stop Jenkins service from console. How can I do that? What's the way to start and restart through console/command line? 回答1: Open Console/Command line --> Go to your Jenkins installation directory. Execute the following commands respectively: to stop:

Command Prompt - How to add a set path only for that batch file executing?

本秂侑毒 提交于 2019-12-17 10:08:15
问题 Basically, I know I can go through my control panel and modify the path variable. But, I'm wondering if there is a way to through batch programming have a temporary path included? That way it is only used during that batch file execution. I don't want to have people go in and modify their path variables just to use my batch file. 回答1: Just like any other environment variable, with SET: SET PATH=%PATH%;c:\whatever\else If you want to have a little safety check built in first, check to see if

Changing default startup directory for command prompt in Windows 7

孤街醉人 提交于 2019-12-17 08:12:11
问题 How do I change default startup directory for command prompt in Windows 7? I usually do the following to start command prompt from C:\ WIN-R (Run Prompt) cmd /K cd C:\ I want to do the following to start command prompt from C:\ WIN-R (Run Prompt) cmd 回答1: While adding a AutoRun entry to HKEY_CURRENT_USER\Software\Microsoft\Command Processor like Shinnok's answer is the way to go it can also really mess things up, you really should try to detect a simple cmd.exe startup vs a script/program