02-13-2019
Quote:
Originally Posted by
AbuAliiiiiiiiii
I'm looking for JAVA code to create file in Linux with specific permission
There is a generic system call for that,
fopen(). Have a look at its man page and report back if anything in there is unclear.
Quote:
Originally Posted by
AbuAliiiiiiiiii
File should be created and saved in Linux in this path \opt\sys\doc by Java with this permission 764
First off, i'd like to question the rationale behind 764. That would mean to give execute rights to the owner and i would be quite surprised if you would want to create an executable.
Second, the path: "\opt\sys\doc" is not a path but rather a filename. Since you do not need to escape regular characters you could also write "optsysdoc" to the same effect. So, what is the path?
I hope this helps.
bakunin
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
Please provide your inputs..
Thanks in Advance,
Mansa (1 Reply)
Discussion started by: mansa
1 Replies
2. UNIX for Dummies Questions & Answers
hello,
I would like to grant full access to a directory which is owned by root and the web application that created it. I have though of adding the permission to the whole world, but for security reason I would like to grant it to one more user.
I have tried this 'chmod -U newUser+wrx... (2 Replies)
Discussion started by: run123
2 Replies
3. Shell Programming and Scripting
In my script, I am creating a file ----> then writting one line (i.e. Timestamp) ----> then FTP'ing. The same script can be executed by many other users.
While other users executing this script, they couldn't Over write this one line (i.e. Timestamp)
My expectation
So I wanted to create a... (2 Replies)
Discussion started by: sbmk_design
2 Replies
4. UNIX for Dummies Questions & Answers
We have utility running on Unix which generates Files with records greater than 32760 , (max supported by Mainframe) .Our requirement is to transfer is file to Mainframe .When we ftp the in binary format it automatically wraps it up..so we are good there...
But now we need to zip and send the file... (2 Replies)
Discussion started by: nishantrk
2 Replies
5. UNIX for Dummies Questions & Answers
Hi Guys,
I want to know is there any method to create a file having 777 permission. I am aware of umask, since it is only giving max. 666 permission for files this is not fulfilling my needs.
Thanks in advance
---------- Post updated at 12:49 AM ---------- Previous update was at 12:31... (10 Replies)
Discussion started by: sanoop
10 Replies
6. Programming
Hello
Please why the files have not created?
Thank you (0 Replies)
Discussion started by: chercheur857
0 Replies
7. Linux
Hi
How can I write a Java program to execute Linux commands? What is the best approach:
Invoking the Linux shell within Java and executing commands
or, using the Java APIs to do the stuff. Since it is platform independent, it'll know itself what to do. We need not check which OS the Java... (1 Reply)
Discussion started by: Dorothy
1 Replies
8. Shell Programming and Scripting
Hi,
I have a file with below format
myfile.txt
aa
aa1
aa2
qq
aa4
ghs
aa6
bbc
gdf
I m looking to create a file where lines begins with aa.
myfile1.txt
aa
aa1
aa2 (4 Replies)
Discussion started by: Litu1988
4 Replies
9. Shell Programming and Scripting
Hello,
I am looking for a UNIX shell script which can help me for access restriction.
1) /home/ram, there are number file with .txt extension, which should be only owned "ram" user.
like as below
ls -lrt *.txt
-rwx------ 1 ram dba 11 Jan 4 2015 PASS1.txt
-rwx------ 1 ram dba 10 Jan 4... (8 Replies)
Discussion started by: mr.trilok
8 Replies
LEARN ABOUT NETBSD
access
ACCESS(2) BSD System Calls Manual ACCESS(2)
NAME
access -- check access permissions of a file or pathname
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <unistd.h>
int
access(const char *path, int mode);
DESCRIPTION
The access() function checks the accessibility of the file named by path for the access permissions indicated by mode. The value of mode is
the bitwise inclusive OR of the access permissions to be checked (R_OK for read permission, W_OK for write permission and X_OK for exe-
cute/search permission) or the existence test, F_OK. All components of the pathname path are checked for access permissions (including
F_OK).
The real user ID is used in place of the effective user ID and the real group access list (including the real group ID) are used in place of
the effective ID for verifying permission.
If a process has super-user privileges and indicates success for R_OK or W_OK, the file may not actually have read or write permission bits
set. If a process has super-user privileges and indicates success for X_OK, at least one of the user, group, or other execute bits is set.
(However, the file may still not be executable. See execve(2).)
RETURN VALUES
If path cannot be found or if any of the desired access modes would not be granted, then a -1 value is returned; otherwise a 0 value is
returned.
ERRORS
Access to the file is denied if:
[EACCES] Permission bits of the file mode do not permit the requested access, or search permission is denied on a component of the
path prefix. The owner of a file has permission checked with respect to the ``owner'' read, write, and execute mode bits,
members of the file's group other than the owner have permission checked with respect to the ``group'' mode bits, and all
others have permissions checked with respect to the ``other'' mode bits.
[EFAULT] path points outside the process's allocated address space.
[EIO] An I/O error occurred while reading from or writing to the file system.
[ELOOP] Too many symbolic links were encountered in translating the pathname.
[ENAMETOOLONG] A component of a pathname exceeded {NAME_MAX} characters, or an entire path name exceeded {PATH_MAX} characters.
[ENOENT] The named file does not exist.
[ENOTDIR] A component of the path prefix is not a directory.
[EROFS] Write access is requested for a file on a read-only file system.
[ETXTBSY] Write access is requested for a pure procedure (shared text) file presently being executed.
SEE ALSO
chmod(2), execve(2), stat(2), secure_path(3)
STANDARDS
The access() function conforms to ISO/IEC 9945-1:1990 (``POSIX.1'').
SECURITY CONSIDERATIONS
The access() system call is a potential security hole due to race conditions. It should never be used. Set-user-ID and set-group-ID appli-
cations should restore the effective user or group ID, and perform actions directly rather than use access() to simulate access checks for
the real user or group ID.
The access() system call may however have some value in providing clues to users as to whether certain operations make sense for a particular
filesystem object. Arguably it also allows a cheaper file existence test than stat(2).
BSD
May 3, 2010 BSD