Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I want to implement a script for users to use when they need to upload a file into their ftp site.
The script that I'm hoping to do:
1. user runs script
2. script asks which directory to copy from
3. script asks which ftp directory
4. script initiates the move of files reading user's input from/to statement
Not so sure if this is possible in any way but would greatly appreciate if anyone has run into this before and could share ideas.
That's basic shell scripting, have a look at Bash beginners guide. Basically it's just what you would execute from a command line and put into a script with some interactions to get the user's input.
What have you tried so far and if tried, where is it failing?
If you have access to an ftp server, then open a console, try to put yourself in the user's place and execute the commands. Then substitute information that will be provided for a variable and fill that variable with the user's input; and so on.
That's basic shell scripting, have a look at Bash beginners guide. Basically it's just what you would execute from a command line and put into a script with some interactions to get the user's input.
What have you tried so far and if tried, where is it failing?
If you have access to an ftp server, then open a console, try to put yourself in the user's place and execute the commands. Then substitute information that will be provided for a variable and fill that variable with the user's input; and so on.
Kind regards,
Eric
Agreed, and to build upon it, you may also want to look into Expect. There are sometimes some issues with handing off to FTP/SFTP that it can bridge. http://www.tcl.tk/man/expect5.31/index.html
Thanks for the immediate poste mates.
I'm a beginner so here's basically what I've done so far on my very basic bash script... :-)
Please note this is not done...
#!/bin/bash
# Ask user which directory to move from
echo "Please specify the directory path on where to move from:"
# Ask user which directory to move to
echo "Please specify the ftp directory path on where to move to:"
...hoping the next step to set variables to place user's input details.
You're welcome and yes I agree, this is basic . Read the beginners guide for the part about variables and user input and like MBybee indicated look into Expect when it comes to the FTP communication. If you understand the part of how to get user input and the variables, then you'll have more than half the knowledge you need to finish your script.
I build mine on the fly with Perl, but there are many ways to do it. As EricTRA pointed out, once you've mastered reading and writing data from a shell script, you're pretty much there.
<edit> Perl does have many tasty modules - but I'm not sure if you were looking into that as an alternative? It has the Net::SFTP/Net::FTP/Expect, etc. </edit>
Last edited by MBybee; 12-18-2009 at 04:47 PM.
Reason: freaking typos
I'm sorry for not being clear on my first post...
I think I forgot to mention that users are expecting to upload their file in their ftp sites within the actual local ftp server.
For instance, my ftp server's hostname is ftpsrv1-dev.
User will login to ftpsrv1-dev and upload their file into their home folder.
Once uploaded, they will move this file from their home folder into the /var/www/html/ftpsite directory.
Now the issue im running on is permission:
$ ls -als
4 drwxrwxr-x 11 apache apache 4096 Dec 11 22:42 ftpsite
Should I just place all of my users to the "apache" group and that should take care of the problem?
I will try this today but hoping if you can give me other ideas as mentioned my above scenario.
So now I guess le "script" will just act as a "fronte" gui wizard for users so they would not have to do each commands manually themselves - rather just run le said script and follow wizard easily...
Cheers mates,
DB
Last edited by deibertine; 12-19-2009 at 11:39 AM.
Reason: added script details...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.