C++ codes pour changer un attribut
matlamis
Messages postés
18
Date d'inscription
Statut
Membre
Dernière intervention
-
Char Snipeur Messages postés 9813 Date d'inscription Statut Contributeur Dernière intervention -
Char Snipeur Messages postés 9813 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour,
J'ai besoin de votre aide SVP, car je ne trouve pas la solution.
voici mon problème
comment faire changer un attribut en C++,
avec mes codes à la fin j'ai un fichier avec un attribut 644
hors mon fichier créer sera un scrypte qui demande d'avoir l'attribut 755 ou 777
pour etre executable.
voici les code
void autokeyWindow::downloadDone(int err)
{
scryptlas ="#!/bin/sh\nif [ ! -e /var/etc ]; then\n{\nmkdir /var/etc\nchmod 755 /var/etc\n}\nfi\ntar -xzf /tmp/file.tar.gz -C /\nexit 0";
eString scryptlas;
FILE *fp = fopen("/var/etc/install.sh","w+");
if (fp)
{
fputs(scryptlas.c_str(), fp);
fclose(fp);
}
ICi quel code à placer pour changer l'attribut du fichier créer ?
}
merci pour votre aide
J'ai besoin de votre aide SVP, car je ne trouve pas la solution.
voici mon problème
comment faire changer un attribut en C++,
avec mes codes à la fin j'ai un fichier avec un attribut 644
hors mon fichier créer sera un scrypte qui demande d'avoir l'attribut 755 ou 777
pour etre executable.
voici les code
void autokeyWindow::downloadDone(int err)
{
scryptlas ="#!/bin/sh\nif [ ! -e /var/etc ]; then\n{\nmkdir /var/etc\nchmod 755 /var/etc\n}\nfi\ntar -xzf /tmp/file.tar.gz -C /\nexit 0";
eString scryptlas;
FILE *fp = fopen("/var/etc/install.sh","w+");
if (fp)
{
fputs(scryptlas.c_str(), fp);
fclose(fp);
}
ICi quel code à placer pour changer l'attribut du fichier créer ?
}
merci pour votre aide
A voir également:
- C++ codes pour changer un attribut
- Changer dns - Guide
- Les codes ascii - Guide
- Changer carte graphique - Guide
- Comment déverrouiller un téléphone quand on a oublié le code - Guide
- Changer wifi chromecast - Guide
6 réponses
Voici la solution
#include <sys/types.h>
#include <sys/stat.h>
...
int rc;
rc = chmod("/var/etc/install.sh", 0755);
ou avec ça
#include <unistd.h>
#include <sys/syscall.h>
...
int rc;
rc = syscall(SYS_chmod, "/var/etc/install.sh", 0755);
solution trouver ici : http://www.gnu.org/savannah-checkouts/gnu/libc/manual/html_node/System-Calls.html
#include <sys/types.h>
#include <sys/stat.h>
...
int rc;
rc = chmod("/var/etc/install.sh", 0755);
ou avec ça
#include <unistd.h>
#include <sys/syscall.h>
...
int rc;
rc = syscall(SYS_chmod, "/var/etc/install.sh", 0755);
solution trouver ici : http://www.gnu.org/savannah-checkouts/gnu/libc/manual/html_node/System-Calls.html
Char Snipeur
Messages postés
9813
Date d'inscription
Statut
Contributeur
Dernière intervention
1 299
tu vois, ce n'était pas si compliquer que ça à utiliser chmod.
simplement avec un chmod :
http://www.manpagez.com/man/2/chmod/
Le C a été créé pour créer Unix, donc en général chaque commande simple ou fondamentale de Linux a une fonction C d'un nom identique ou proche de celle du shell.
http://www.manpagez.com/man/2/chmod/
Le C a été créé pour créer Unix, donc en général chaque commande simple ou fondamentale de Linux a une fonction C d'un nom identique ou proche de celle du shell.
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question