nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

set a permission to open a .txt

This is a discussion on set a permission to open a .txt within the Coding in General forums, part of the Development/Scripting category; how I can set a permission to open a .txt file from program in c++ with library <fstream> working from ...


Go Back   nixCraft Linux Forum > Development/Scripting > Coding in General

Linux answers from nixCraft.


Coding in General Discussion on PHP/Perl/Python/Ruby/GNU C or C++. MySQL, PgSQL and (X)HTML or any other programming languages you want.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 16-05-2009, 05:57 PM
Junior Member
User
 
Join Date: May 2009
OS: Debian
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
olya003 is on a distinguished road
Question set a permission to open a .txt

how I can set a permission to open a .txt file from program in c++ with library <fstream> working from ssh in fedora OS.
Reply With Quote
  #2 (permalink)  
Old 18-05-2009, 04:11 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 244 Times in 183 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

To change permissions of a file use chmod() or fchmod() under C compiler. You need to include <sys/stat.h>. I've no idea about c++ but these two are used functions under UNIX / Linux oses.

Code:
if ( chmod("/path/to/text.file",0666) == -1 ){
   /* error */
}
else{
   /* successful */
}
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Chmod and Permission.. some on can help me. hrothgar Linux software 2 13-01-2009 01:02 AM
Slave DNS permission problem asim.mcp All about FreeBSD/OpenBSD/NetBSD 0 19-10-2008 07:19 PM
How to set folder permission enochalbert Ubuntu / Debian 1 25-09-2008 10:19 PM
Permission asim.mcp Linux software 1 12-08-2006 03:40 AM
Permission Problems on WIKI Farm rcordeiro Linux software 5 22-06-2006 11:04 PM


All times are GMT +5.5. The time now is 04:32 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38