problem with adding php code with variables using printf in linux
up vote
0
down vote
favorite
The problem is , when i'am using python to execute that command line
os.system("sudo -u "+self.user+" printf "+ self.data +" > "+ self.path)
is updating the file with new data but not with variables just with space
example
<?php
$test = "dddd";
echo "please work".$test;
will be after execute command line to
<?php
= "dddd";
echo "please work".;
without variables
So how can i solve this problem ?
python bash
add a comment |
up vote
0
down vote
favorite
The problem is , when i'am using python to execute that command line
os.system("sudo -u "+self.user+" printf "+ self.data +" > "+ self.path)
is updating the file with new data but not with variables just with space
example
<?php
$test = "dddd";
echo "please work".$test;
will be after execute command line to
<?php
= "dddd";
echo "please work".;
without variables
So how can i solve this problem ?
python bash
You should surround with a single quote:os.system("..." + "printf '" + self.data + "' > .."
(Note the single quote). Also, you wouldn't have run into this issue had you used Popen with a list argument instead of os.system(..).
– UltraInstinct
Nov 11 at 0:00
it's solved the problem but the code added in the file with " code " like a string
– eslam alshbah
Nov 11 at 0:25
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
The problem is , when i'am using python to execute that command line
os.system("sudo -u "+self.user+" printf "+ self.data +" > "+ self.path)
is updating the file with new data but not with variables just with space
example
<?php
$test = "dddd";
echo "please work".$test;
will be after execute command line to
<?php
= "dddd";
echo "please work".;
without variables
So how can i solve this problem ?
python bash
The problem is , when i'am using python to execute that command line
os.system("sudo -u "+self.user+" printf "+ self.data +" > "+ self.path)
is updating the file with new data but not with variables just with space
example
<?php
$test = "dddd";
echo "please work".$test;
will be after execute command line to
<?php
= "dddd";
echo "please work".;
without variables
So how can i solve this problem ?
python bash
python bash
edited Nov 10 at 23:50
asked Nov 10 at 23:44
eslam alshbah
33
33
You should surround with a single quote:os.system("..." + "printf '" + self.data + "' > .."
(Note the single quote). Also, you wouldn't have run into this issue had you used Popen with a list argument instead of os.system(..).
– UltraInstinct
Nov 11 at 0:00
it's solved the problem but the code added in the file with " code " like a string
– eslam alshbah
Nov 11 at 0:25
add a comment |
You should surround with a single quote:os.system("..." + "printf '" + self.data + "' > .."
(Note the single quote). Also, you wouldn't have run into this issue had you used Popen with a list argument instead of os.system(..).
– UltraInstinct
Nov 11 at 0:00
it's solved the problem but the code added in the file with " code " like a string
– eslam alshbah
Nov 11 at 0:25
You should surround with a single quote:
os.system("..." + "printf '" + self.data + "' > .."
(Note the single quote). Also, you wouldn't have run into this issue had you used Popen with a list argument instead of os.system(..).– UltraInstinct
Nov 11 at 0:00
You should surround with a single quote:
os.system("..." + "printf '" + self.data + "' > .."
(Note the single quote). Also, you wouldn't have run into this issue had you used Popen with a list argument instead of os.system(..).– UltraInstinct
Nov 11 at 0:00
it's solved the problem but the code added in the file with " code " like a string
– eslam alshbah
Nov 11 at 0:25
it's solved the problem but the code added in the file with " code " like a string
– eslam alshbah
Nov 11 at 0:25
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244524%2fproblem-with-adding-php-code-with-variables-using-printf-in-linux%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You should surround with a single quote:
os.system("..." + "printf '" + self.data + "' > .."
(Note the single quote). Also, you wouldn't have run into this issue had you used Popen with a list argument instead of os.system(..).– UltraInstinct
Nov 11 at 0:00
it's solved the problem but the code added in the file with " code " like a string
– eslam alshbah
Nov 11 at 0:25