FTP scripting on unix?

kukyfrope

Senior member
Mar 21, 2005
344
0
0
I'm trying to learn how to create a script that can SFTP into a server, issue chmod all directories in 1 specific main directory, and then chmod 1 file (same name across all dir's) in each directory of the main directory. This would be executed manually by a user possibly without shell access. Could somebody throw something out there as a solution or give me a place to start? Thanks!
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
sftp isn't really made for this, are you using sftp just so you don't have to give that user account a shell? And what are you doing that's breaking the permissions in the first place, that would seem to be the logical place to fix the issue.
 

kukyfrope

Senior member
Mar 21, 2005
344
0
0
SFTP is a security measure for the server itself and is required to connect.

The permissions are not breaking. The user is publishing new HTML and streaming media to the web via a program made by Accordent Technologies. We have modified the files to run some required scripting and the server requires the files to be 700, opposed to the 664 that Accordent publishes them as. The cilent is not too web savvy, but is capable of using an FTP app to manually login and chmod new files, but I figured it was something that could be done much easier with a script and would be a learning process for me as well.

We could setup the client to login via putty and run a script that lives on the server also. I just didn't know if it was worth explaining to them.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
SFTP is a security measure for the server itself and is required to connect.

I know what sftp is, but it's just a subsystem of ssh and ssh would be better for normal command scripting.

The user is publishing new HTML and streaming media to the web via a program made by Accordent Technologies. We have modified the files to run some required scripting and the server requires the files to be 700, opposed to the 664 that Accordent publishes them as. The cilent is not too web savvy, but is capable of using an FTP app to manually login and chmod new files, but I figured it was something that could be done much easier with a script and would be a learning process for me as well.

Is there a way to change Accordent's (or the account it logs in as) umask so that they get created as 700?
 

kukyfrope

Senior member
Mar 21, 2005
344
0
0
I made the statement about SFTP to state that it's required at the server level and I can't change that setting on the server. I had no dobut you knew what it was

The current umask on the account is 0002. Could I specify a default permission for all .shtml that upload under a certain directory (since I don't want them to be executable in other directories) or can it only affect account-wide? Could it be session-based, or set on connect then reset on disconnect in some way? SHTML needs execute permissions because we're running the scripts via suexec.

Forgive my lack of unix command knowledge and thanks for the help so far Nothinman
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
I made the statement about SFTP to state that it's required at the server level and I can't change that setting on the server. I had no dobut you knew what it was

Well if you have no control over the server and sftp is it, then I guess that's it =)

The current umask on the account is 0002.

Well then you could probably get them created as 600 by changing the umask, but not 700 since the umask specifies what permissions to take a way from the rights given in the open(2) call.

Now the real question is where will this script be run? If it's a Windows box you'll have a more difficult time since there's no ssh/sftp clients that come with it. Giving them putty and having them run the script on the server is probably the easier solution, unless there's an SFTP client for Windows that can do the scripting you need. The unix script would be just a few find/chmod commands but via an FTP client would probalby be more complicated.
 

Armitage

Banned
Feb 23, 2001
8,086
0
0
CURL has wrappers in a number of scripting languages - I've used it with Python quite a bit. But I've never worked with SFTP.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
CURL has wrappers in a number of scripting languages - I've used it with Python quite a bit. But I've never worked with SFTP.

Can CURL change permissions on files though?
 

Armitage

Banned
Feb 23, 2001
8,086
0
0
Originally posted by: Nothinman
CURL has wrappers in a number of scripting languages - I've used it with Python quite a bit. But I've never worked with SFTP.

Can CURL change permissions on files though?

I dunno - I've never had to script that kind of thing.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Looking at the man page it looks like you can use the -Q option to have it execute commands before or after the transfer, so it would be better to integrate that with the initial upload process instead of a bandaid for fixing the permissions afterwards.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |