- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- FTP scptiing question
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2006 12:34 PM
03-07-2006 12:34 PM
I need help with renaming a file during my FTP script execution from my Linux server RHAS 3.0 to my Windows FTP server. Also, what would be the best way to pickup a long file name, such as PAAAAAPAAAAA20060307.txt and rename from PAAAAA20060307.txt to PAAAAA20060307.old after I am done with the FTP procedure?
Thanks,
J
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2006 03:47 PM
03-07-2006 03:47 PM
Solutionyou can include it in script that will run after the ftp operation:
e.g.
filelist=`ls -1 *.txt`
for filen in $filelist; do
new=`echo ${filen} |sed s/txt/old/g`
mv ${filen} $new
echo renamed $filen to $new
done
hope this helps!
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2006 06:42 AM
03-08-2006 06:42 AM
Re: FTP scptiing question
Any ideas??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2006 06:53 AM
03-08-2006 06:53 AM
Re: FTP scptiing question
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2006 08:12 AM
03-08-2006 08:12 AM
Re: FTP scptiing question
What am I missing here? Here's an example:
fooo01
foolprof
prompt
umask 000
lcd e:\ftpusers\temp\IN
cd /u09/data/bin/in
ascii
mput *test_file*.txt
bye
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2006 08:34 AM
03-08-2006 08:34 AM
Re: FTP scptiing question
umask 000
ftp server << EOD
your ftp commands here
EOD
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2006 09:04 AM
03-08-2006 09:04 AM
Re: FTP scptiing question
Please help!
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2006 09:20 AM
03-08-2006 09:20 AM
Re: FTP scptiing question
vi ftpscript.sh and insert the following lines:
#!/bin/sh
umask 000
your ftp command here
Make it executable:
chmod u+x ftpscript.sh
Run it.
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2006 02:12 PM
03-08-2006 02:12 PM
Re: FTP scptiing question
Now, what I can tell is that when I typed unmask, I can see it was set 022 by default. if I set the umask to 777 (umask 777 test_account) - this would work just fine. How do I make this umask 777 to set permanently for this account?
Thanks,
J
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2006 03:23 PM
03-08-2006 03:23 PM
Re: FTP scptiing question
will it be possible to do the FTP from the Linux server instead?
would be then "mget" instead of "mput"?
there may be some configuration required on the FTP server.
revert
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2006 12:50 AM
03-09-2006 12:50 AM
Re: FTP scptiing question
Please let me know if I'm on the right track or not.
Thanks,
J
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2006 01:31 AM
03-09-2006 01:31 AM
Re: FTP scptiing question
If you want the umask for the user to be 000 (so file permissions are 666), you can add the "umask 000" to the user's .profile or .bashrc in the home directory. However, this will only affect login sessions. I think you can set the umask for the cron job in Linux's cron implementation so you wouldn't need to do the chmod in your script. Or using chmod after the ftp, as you've done, will work too.
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2006 04:16 AM
03-09-2006 04:16 AM
Re: FTP scptiing question
Thanks,
J
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2006 03:19 PM
03-09-2006 03:19 PM
Re: FTP scptiing question
in fact, if you have inetd you could just configure your ftp services on your linux server such that all file uploaded gets a predetermined mode.
e.g.
ftp stream tcp nowait root /usr/lbin/ftpd ftpd -l -u 002 -a
please check.
(in my suse linux at hand,we don't have it. On hp-ux, we do have it. On redhat, we need to install the inetd package)
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2006 09:49 AM
03-10-2006 09:49 AM
Re: FTP scptiing question
Thanks,
J
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2006 04:10 PM
03-10-2006 04:10 PM
Re: FTP scptiing question
thats good news :)
I have not tried it on linux.
On hp-ux, we have setup ftponly accounts.
will try to get you some notes on how it was done on hpux.
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2006 04:16 PM
03-10-2006 04:16 PM
Re: FTP scptiing question
can you please try this?
=============================
1. Create a bogus shell like /usr/bin/ftponly - just put a message in there in case he tries to login on server: Create a group, like "ftpgroup" and put him in it.
Example bogus shell:
#!/bin/sh
/usr/bin/cat << XX
***********************************************************************************************
* ACCESS DENIED: You may use FTP, but you may not login with this account! *
***********************************************************************************************
XX
/usr/bin/sleep 5
2. Edit (or create) /etc/shells that looks like this (make sure that it includes your bogus shell) :
/usr/bin/sh
/sbin/sh
/usr/bin/ksh
/usr/bin/csh
/usr/bin/ftponly
3. For true "restricted" ftp accounts, Edit user in /etc/passwd with vipw:
(These accounts will not have a regular shell, so they cannot telnet.)
Change the home directory entry to put the "root" level that you want this user to be able see on one side of a period (.)
The other side of the period is where he intially lands (relative to the new "root") in when he ftps to the server.
Example:
ftpuser:jo/469sTHoYRQ:105:101:ftp account,,,:/opt/apache/ftpdir/./:/usr/bin/ftponly
Do NOT forget the trailing "/" just before the separating "." between the directories above.
4. For "restricted" ftp accounts, you also need to create or edit /ftpd/ftpaccess
(See ftpaccess manpage for mind-boggling details.)
Example /etc/ftpd/ftpaccess:
class all real,guest *
guestgroup www ftpgroup
upload * * yes * * 0775 dirs
My understanding of the above:
# defines a "class" of all, real, and anything starting with guest*
# defines 2 "guestgroup" "groupnames," called "www" and "ftpgroup" --- if an ftp user is a REAL /etc/passwd account AND the user belongs to one of these groups, then their ftp session is treated just like anonymous ftp. If a user is in one of these groups they cannot cd to anything outside of their home directory, cannot change user, or password, etc.
# allow "upload" access to any directory, ownership group will be those of the ftp user, directories may be created
When you setup a user like this, the user acts just like an anonymous ftp account. So, ftpd does a chroot to the selected directory. However, no files, libraries, etc that are outside this restricted piece of the file system are available anymore to this user. So commands like ls won't work anymore. To just get ls working, you need to create a local usr/bin under the new "root" directory. Change the permissions on these dirs to 555 - owned by root. Then copy /sbin/ls into the new usr/bin and chown to root and chmod 111 on the ls executable.
5. Put ANY (restricted or not) logins that you do NOT want to ftp in /etc/ftpd/ftpusers.
Hint: use the following command to create the file (NO ONE on this list will be able to ftp):
cat /etc/passwd | awk -F: '{print $1}' > /etc/ftpd/ftpusers
Then remove those users that you DO want to ftp from ftpusers.
6, Setup the ftpd entry in inetd.conf like this:
ftp stream tcp nowait root /usr/lbin/ftpd ftpd -a
(note: ftpaccess file must exist!)
(The ftpd -a tells the daemon to access the /etc/ftpd/ftpaccess configuration file.)
7. Restart inetd like this inetd -c (works on hp-ux).
kind regards
yogeeraj