- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: perl script - chown within/after ftp?
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
Discussions
Discussions
Discussions
Forums
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
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
тАО11-04-2009 07:34 PM
тАО11-04-2009 07:34 PM
I have written a perl script to ftp a file from a Windows XP PC to a HP-UX server using the Net:FTP module.
The ftp part is working fine but I need to 'chown' the file once it is ftp-ed over in the UX directory.
How can it be done?
This is how the script looks like :
use Net::FTP;
$ftpobj = Net::FTP -> new ("myserver");
$ftpobj -> login("id","password");
$ftpobj -> cwd ("/home/temp");
$ftpobj -> ascii;
$ftpobj -> put (myfile);
$ftpobj -> quit;
I don't think its possible within the ftp command - "$ftpobj -> chown (id, group, filename)" doesn't work.
Do I have to separately (within the script) do a 'telnet' and then 'chown'?
Thanks !
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2009 08:52 PM
тАО11-04-2009 08:52 PM
Re: perl script - chown within/after ftp?
Not a very complete description of this
system.
> [...] I need to 'chown' [...]
Why? Who owns the files now, and whom would
you like to own them?
The FTP server on my HP-UX 11.31 system seems
to offer a "SITE CHMOD" command, but "chown"
typically requires some unusual privilege, so
I wouldn't expect an FTP server to offer it.
> [...] do a 'telnet' and then 'chown'?
And as whom were you planning to log in to do
that job? (You want to put _which_ password
into this script?) Even rsh/remsh can offer
better security than a password embedded in
a script. Ssh could be safer than rsh/remsh
for executing a remote command, but if you
give some user the power to do chown, what
else have you made possible?
If you care not at all about security, then
tasks like this get easier.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2009 11:59 PM
тАО11-04-2009 11:59 PM
Re: perl script - chown within/after ftp?
Thanks for the reply.
It's actually a UX 11v23 test system that I'm playing with so security is not a concern for now.
There's a series of steps that I'm trying to automate whereby I :
1) ftp a file from my PC to the UX server using root
2) login as root and chown the file to a specific user
The easiest way will be to ftp using that user but unfortunately, no one can remember the password and the file is used by an application running under that user ID - so the need for the chown.
The chown is pretty straight forward, e.g. chown user:ugroup filename
Nothing fancy and no need for any unusual privileges.
Hope this clarifies.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-05-2009 12:09 AM
тАО11-05-2009 12:09 AM
SolutionNot clear why you want to run chown, however if you want to do that anyway, you can use the Net::Telnet module within your perl script so that it does the 'chown' after the file is succesfully transferred.
use Net::Telnet;
$telnet = new Net::Telnet ( Timeout=>10, Errmode=>'die' Prompt => '/\$ $/i'); $telnet->open('host or IP'); $telnet->login('username', 'passwd'); print $telnet->cmd('chown usr:grp /path/to/file');
hth
regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-05-2009 05:36 AM
тАО11-05-2009 05:36 AM
Re: perl script - chown within/after ftp?
> The easiest way will be to ftp using that user but unfortunately, no one can remember the password and the file is used by an application running under that user ID - so the need for the chown.
Why don't you (as 'root') change the password of the target user to something you know and then do your FTP as that user?
You could also use SFTP (I suggest Perl's 'Net::SFTP::Foreign' module) having setup public keys in lieu of hardcoding cleartext passwords.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-05-2009 06:53 AM
тАО11-05-2009 06:53 AM
Re: perl script - chown within/after ftp?
> password [...]?
Especially considering:
> It's actually a UX 11v23 test system that
> I'm playing with so security is not a
> concern for now.
Sometimes the easy way really is the easy
way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-05-2009 04:04 PM
тАО11-05-2009 04:04 PM
Re: perl script - chown within/after ftp?
Using root to change the password of the target user is indeed a good
solution but my fear is that once changed, things may not work (either due
to configuration, hardcoding, etc ) - that's why I'm hesitant to go that way.
Thanks again for all the help and suggestions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2009 03:39 AM
тАО11-06-2009 03:39 AM
Re: perl script - chown within/after ftp?
system("chown user:ugroup filename");
with the root user
or
system("sudo chown user:ugroup filename");
and by grating passwordless sudo to the user executing the perl script
Unix operates with beer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2009 03:48 AM
тАО11-06-2009 03:48 AM
Re: perl script - chown within/after ftp?
Simply save the old passwd entry and if problems, you can always put it back.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2009 08:29 PM
тАО12-30-2009 08:29 PM