LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-19-2009, 10:31 PM   #61
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454

Quote:
Originally Posted by circuit_girl View Post
Code:
mkdir "temp", 0777;    
system ("chmod 777 temp");  
do
{
  print "What files or folders do you want to send? (Hit ENTER after each file, to finish hold CTRL+D)";
  $user_entry = <STDIN>;
  if ( $user_entry )                                                      #IF FILE EXSISTS REMOVE THE PATH FOR TEMP FILE NAME AND ALL UNSAFE CHARACTERS####
  {
    $filename = $user_entry;
    my ( $name, $path, $extension ) = fileparse ( $filename, '\..*' );    #REMOVE THE PATH
    $filename = $name . $extension;                                       #CONCANONATE THE NAME OF FILE AND EXTENTION WITHOUT PATH
    system ("cp $user_entry $filename");
    print "This is what you entered; $user_entry  with the file name of: $filename \n";
  }
}
while ($user_entry);

print "Thank you for using my AMAZING emailer\n";
I have this right now but I am not sure how to go about getting files from a different location then teh current directory. I have some files that I want to sent that are located up the file tree and down some. how do I copy those files into the current temp directory I have created.

I am going to delete this directory and its contents when the emailer is done sending. What is the full comand I can use? rmdir -a???

thank you
Why do you have both

Code:
mkdir "temp", 0777;    
system ("chmod 777 temp");
?

Regarding "I have this right now but I am not sure how to go about getting files from a different location then teh current directory." and the copy part - you are using

Code:
cp $user_entry $filename
, so $user_entry can be full or relative part, right ? I.e. what's the problem with it ?

I think, however, you are missing a conceptual problem:

suppose user has

foo/bar.txt
doo/bar.txt

files, and through your script he/she copies them to your 'temp' directory - obviously only one of the two file will remain.

What are you going to do about this ?
 
Old 04-19-2009, 10:46 PM   #62
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by circuit_girl View Post
Code:
mkdir "temp", 0777;    
system ("chmod 777 temp");
Use Perl's own chmod function. perldoc -f chmod
Quote:
Code:
    system ("cp $user_entry $filename");
use Perl's File::Copy
Code:
use File::Copy;
copy("file1","file2") or die "Copy failed: $!";
Quote:
I am going to delete this directory and its contents when the emailer is done sending. What is the full comand I can use? rmdir -a???
thank you
perldoc -f rmdir (for removing empty directory.
Or use File::Path module's rmtree()
 
Old 04-19-2009, 10:56 PM   #63
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by ghostdog74 View Post
Use Perl's own chmod function. perldoc -f chmod
...
Directory can be created with the necessary mask, changing 777 -> 777 through the second command simply doesn't make sense.
 
Old 04-20-2009, 12:23 AM   #64
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by Sergei Steshenko View Post
Directory can be created with the necessary mask, changing 777 -> 777 through the second command simply doesn't make sense.
i know. my context is on using Perl's internal functions as far as possible.
 
Old 04-20-2009, 02:34 AM   #65
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by ghostdog74 View Post
i know. my context is on using Perl's internal functions as far as possible.
Yes, and the first command was Perl internal function .
 
Old 04-20-2009, 03:43 AM   #66
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by Sergei Steshenko View Post
Yes, and the first command was Perl internal function .
i am referring to h(er|is) excessive use of system() calls.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
i need to write a script that automatically logins venix Linux - Newbie 3 03-03-2009 01:34 PM
Strange remote logins after starting a gnome session Clemente Linux - Desktop 2 11-11-2008 02:14 PM
Looking for software to track logins and commands with auto-email DukeLeto Linux - Software 1 07-20-2007 05:14 PM
scripting the unix command script lmcthbe Linux - General 7 05-28-2003 02:49 PM
How to schedule unix script periodically from unix os level??? gopi_20us Programming 2 03-11-2002 06:45 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration