How to use chmod command inside ftp block?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to use chmod command inside ftp block?
# 1  
Old 05-13-2013
How to use chmod command inside ftp block?

hi,

i want to use chmod command inside ftp. so that what ever files are transfered to the local server will hav 664 permission.

if i use chmod inside ftp , the file permissions gets changed in the remote server and when the file is transffered to local server using get command, it does not have the write permission for group.

Code:
ftp -n $remote<<_ftp
  quote USER $remote_user
  quote PASS $remote_pass
  chmod 664 p.txt
  get p.txt
  bye
_ftp


when i execute this , at remote server file permission is changed to 664, but in local server permission is still 644. can any1 tell how to change the file permission in local server?
# 2  
Old 05-13-2013
its because of the umask set on your local server.
# 3  
Old 05-13-2013
is there any other way to get the files with 664 permission??

is it possible to set umask to 0002 for a particular directory in local server, so that what ever file are transffered to that directory only can have 664 permission.
# 4  
Old 05-13-2013
Unfortunately you cant set it per directory.. You can run the commands on local server with !

after getting the file on local server run !chmod 664 /dir/filename will do the job
This User Gave Thanks to vidyadhar85 For This Post:
# 5  
Old 05-13-2013
Run the umask command before you run ftp to change your local umask to something you prefer.
# 6  
Old 05-14-2013
i dnt have the root privileges to set the umask.

all my shell scripts are owned by root user, i am logging in as "etcftp". when i run the shell script from command prompt to transfer file from remote server to local server, files transfers successfully and the owner of the file is me (etcftp).

when i try to call the shell script via a web page, the shell script is called and the files are transffered, but the owner of the files transffered becomes "apache".

from web page i am calling the shell script like this.

html page calls a perl script and perl script calls the shell script passing the required arguments to shell script.

i thing sice i am initiating the transfer from web page as "apache" user, the shell scripts are run by the apache.

i want the shell script to run by user "etcftp".

is it possible to change the user from "apache" to "etcftp" before calling the shell script. so that etcftp will call the shell script and the files transffered will be owned by "etcftp"

if any other solution, please suggest.
# 7  
Old 05-14-2013
Quote:
Originally Posted by Little
i dnt have the root privileges to set the umask.
You do not need root privileges to run umask.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to redirect the output of a command inside ftp block?

hi, i am using ftp to get files from remote server. inside the ftp i want to us ls -ltr command and send the output of it to a file. ftp -n remote_server <<_FTP quote USER username quote PASS password prompt noprompt pwd ls -ltr get s1.txt bye _FTP i... (4 Replies)
Discussion started by: Little
4 Replies

2. Shell Programming and Scripting

FTP Command inside If condition

Hi All, I am facing a alien problem in unix shell script. i have a requirement where i have to check first whether a particular file has been created or not if that file has been created then that file needs to be ftped to a particular dir. My Code is like that Success='code for file... (3 Replies)
Discussion started by: aryan_styles
3 Replies

3. Shell Programming and Scripting

Apply `chmod` for multiple files through FTP

Hi all, Can you please help me in this aspect. I devoloped a FTP script to copy a directory to remote server. Now i got stuck-up in changing the file permissions for all the files in directory. I tried to change the permissions of single file and I did it but failed in changing... (3 Replies)
Discussion started by: Chanakya.m
3 Replies

4. UNIX for Dummies Questions & Answers

users need to chmod on newly ftp'd files

Is there a way to specify 774 permissions for a file uploaded to an app server via ftp without the users logging in and doing a chmod on the file they just put? I understand they were doing this with an old shared account, and it was working. When they started using their own accounts it stopped... (1 Reply)
Discussion started by: jgentile
1 Replies

5. Solaris

chmod command

Hi, I want to create one user who has right to run chmod command in solaris, Any Idea? (7 Replies)
Discussion started by: manoj.solaris
7 Replies

6. UNIX for Advanced & Expert Users

MVS->Unix FTP : Using chmod as part of FTP.

We are transferring file from mainframes to unix, & in FTP process itself we would like to set access rights for unix machine. Has anyone used chmod command in association with site command in ftp? How it should be used? Thanks in advance. (1 Reply)
Discussion started by: videsh77
1 Replies

7. Shell Programming and Scripting

FTP inside a block of code

I need help on the code below. I am getting a compile error syntax error at line 283 : `<<' unmatched Looks like it doesn't like the << on the ftp line below. If I ran the code outside of this block everything work fine, but when I put in a block of code or in a function, I got syntax error. I... (1 Reply)
Discussion started by: leemjesse
1 Replies

8. Shell Programming and Scripting

Script to CHMOD using FTP

Hello everybody ! Excuse me guys. I posted this In EXPERT group as well, but they don't seems to find this problem of that level, so posting it here as well.. I am developing a FTP script which will copy all the files from one server to another server and then I need to use CHMOD 755 * to... (1 Reply)
Discussion started by: sdlayeeq
1 Replies

9. UNIX for Dummies Questions & Answers

Chmod +ftp

Is there a wayto chmod via ftp for my webpage and change all files and folders from one point down? There is way too many files and folders in this to do one at a time. Thanks! (3 Replies)
Discussion started by: stormiee
3 Replies

10. UNIX for Dummies Questions & Answers

ftp protocol and quot site chmod 0

i do have a problem with the transaction of pdf-files from a server to another. there was a guy who told me about this command wich i should build in my ftp.put()-method in java. the command called: about quote site chmod 0 filename.. i think its something about filerights but does someone know... (1 Reply)
Discussion started by: calmacroi
1 Replies
Login or Register to Ask a Question