‏إظهار الرسائل ذات التسميات command. إظهار كافة الرسائل
‏إظهار الرسائل ذات التسميات command. إظهار كافة الرسائل

الأحد، 5 يناير 2014

Check the Errorlevel value and process the if command

The "problem" with your code is that when the parser reach that line, the %errorlevel% variable is replaced with its value, and then the line is executed. So, any change to the value of the variable is not seen. The "usual" way of handling this cases is enabling delayed expansion and change the %errorlevel% sintax with !errorlevel! to indicate the parser that the value will change and need to be retrieved at execution time.

But, in this case, as you have the requirement of a "one liner", change the if test to

if errorlevel 1 (echo "SQL Not Installed") else (echo "SQL Installed")

A standard construct to check for errorlevel without reading the variable value.

You have also the posibility to code it as

reg query .... && echo Installed || echo Not Installed

This executes the reg command (with all your parameters, of course). On success, the command after && is executed. On failure the command after || is executed.


View the original article here

Command Line Password Prompt in PHP

I'm writing a command line tool to help my web app. It needs a password to connect to the service. I'd like the script to show a password prompt so I don't have to pass it as a command line argument.

That's easy enough, but I'd like it to not echo the password to the screen as it's typed. How can I do this with PHP?

Bonus points for doing it in pure PHP (no system('stty')) and replacing the characters with *.

EDIT:

The script will run on a unix like system (linux or mac). The script is written in PHP, and will most likely stay like that.

Also, for the record, the stty way of doing it is:

echo "Password: ";system('stty -echo');$password = trim(fgets(STDIN));system('stty echo');// add a new line since the users CR didn't echoecho "\n";

I'd prefer to not have the system() calls in there.


View the original article here

الجمعة، 27 ديسمبر 2013

Grid view row command showing error

I am getting this error:

Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

This is my code:

protected void GridViewCommandEventHandler(object sender, GridViewCommandEventArgs e){ if (e.CommandName == "view") { int row_id = Convert.ToInt32(e.CommandArgument); var result = (from test in je.jobposting where test.id==row_id select test).FirstOrDefault(); Session["id"] = result; } else { int row_id = Convert.ToInt32(e.CommandArgument); var result = (from test in je.jobposting where test.id==row_id select test).FirstOrDefault(); je.DeleteObject(result); je.SaveChanges(); Response.Redirect (""); }}

View the original article here