0

I have a .php file which name is console.php and I want to set password from command like with this script all things is ok and I use it like this

php console.php user password
// f.e.
php console.php admin 1234

But when I want to use the a strong password which contain a single quote f.e. 123'456 it does not work and go to the next line like this

azibom@azibom:~$ php console.php admin 123'456
> 

Is there any solution for it?

user3783243
  • 5,368
  • 5
  • 22
  • 41
azibom
  • 1,769
  • 1
  • 7
  • 21
  • [How to pass a password with quotes and single quotes in terminal?](https://stackoverflow.com/questions/29615061/how-to-pass-a-password-with-quotes-and-single-quotes-in-terminal) – Alive to die - Anant Feb 15 '21 at 13:10

1 Answers1

1

You can escape characters which have special meaning to the shell: 123\'456.

user1934428
  • 19,864
  • 7
  • 42
  • 87
  • yes I know, I can also put them in the double qoute like this "123'456" but I want to know that, is there any other solution for it – azibom Feb 15 '21 at 16:03
  • 2
    @azibom If you mean "is there any solution that doesn't require quoting or escaping", the answer is no. Any command you type in a shell command line must be written in the shell language, and in the shell language an unescaped and unquoted single-quote means "this is the beginning of a quoted string, that ends with another single quote". You cannot change this meaning, it is built into the shell language. – Gordon Davisson Feb 15 '21 at 21:22
  • @azibom: Yes, it is: Store the password (using your favorite text editor) into a file, say `secret_password.txt`, and do a `php console.php admin $( – user1934428 Feb 16 '21 at 07:53
  • @user1934428 Using `$( – Gordon Davisson Feb 18 '21 at 23:31
  • 1
    @GordonDavisson : Of course, I forgot the quotes: `php console.php admin "$( – user1934428 Feb 19 '21 at 07:52