944,172 Members | Top Members by Rank

Ad:
  • Perl Discussion Thread
  • Unsolved
  • Views: 3405
  • Perl RSS
You are currently viewing page 1 of this multi-page discussion thread
Jun 7th, 2005
0

Save ME

Expand Post »
I have very little experience that’s why I need some help to get started I have been given a task to write a perl script in Linux and I don’t know from where to begin. Can anyone help me out with this please.

1. Move files from Windows 98 machine to this linux machine folders and sub-folders.
(I mean \\machine\c:\list\*.* to /var/www/list/) (\\machine\c:\lot_repos\*.* to /var/www/lot_repos/) & a long list is there.

2. Move the above files at a given hour of the day.

3. CHMOD this files to 644.

4. Generate a list of reports of those moved files.

As a newbie I swear that I don’t know about this from where to begin writing this script. Please some one help & save me.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
anthony05 is offline Offline
7 posts
since Jun 2005
Jun 7th, 2005
0

Re: Save ME

Is This a homework project, or something for work, or something for yourself? This makes a difference in the approach that you will have to take in order to make some of the options work a specific way.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Jun 7th, 2005
0

Re: Save ME

Hello,
I have already setup samba and both windows and linux are able to communicate.

This is NO homework project or something for myself? This is real work which I am facing in the office. They want this to be done immediately and i being a new to this is unable to do. Kindly rescue me from this as the main person who was handling all this has been fired and now i am on the fire?

Kindly some one help me. Please
Thanking you in advance.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
anthony05 is offline Offline
7 posts
since Jun 2005
Jun 7th, 2005
0

Re: Save ME

The reason I said this, is because it's very possible to use what's called "CRON" to have the script run at certain times and/or certain dates. On your Unix Machine, Do A man on cron: man cron
It will give you a whole lot of information about setting up any script or program to run at a certain date and time.... I can help you with all the other things.... chmoding, and moving the files (I think....I'm not sure how you reference a samba partition, is just mounted in a folder?)....
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Jun 8th, 2005
0

Re: Save ME

Hello,
Thanks for your positive response to me. Today I have tried the cron (scheduled) in my system.
We have mounted samba partition in a folder.
Please can you help in writing the script that will do the job.
moving,chmod & a report.
Awaiting for the reply. Thank you in advance.
Bye
Reputation Points: 10
Solved Threads: 0
Newbie Poster
anthony05 is offline Offline
7 posts
since Jun 2005
Jun 8th, 2005
0

Re: Save ME

Ok, What Directory on the unix box is the windows share mounted on? (what is the unix path to the samba share)?
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Jun 9th, 2005
0

Re: Save ME

Thanks for helping me Comatose

[global]
workgroup = SCTHOME
server string = SCT Server
encrypt passwords = yes

[downloads]
path = /var/www/list

[sctdata]
path = /var/www/lot_repos

Once again thanks for giving me support.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
anthony05 is offline Offline
7 posts
since Jun 2005
Jun 9th, 2005
0

Re: Save ME

Wait, I'm still confused..... this program needs to copy files from windows to linux.... ok good. Now, we have Samba setup. Samba lets us share a directory between windows and linux.... ok great... you have 2 shares....downloads and sctdata, and these two shares.... go to /var/www/list and /var/www/lot_repos respectively. So far still so good.... so, if the windows box or windows user copies files to the downloads or sctdata share.... I'm seeing them automagically show up in /var/www/list and /var/www/lot_repos.... right? So Samba is doing all the work so far.... it's even copying the files from windows to linux right? So, if not mistaken, the perl program has no need to do anything other than chmod files, and print a report right?
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Jun 9th, 2005
0

Re: Save ME

I have a similar situation. I download media files and encode movies on my windows box, then use a script to copy them over to my linux(freevo) video server. I am using bash, it seems to be the easiest. A 'for loop' would seem the easiest way to do it. This would be the general idea
Perl Syntax (Toggle Plain Text)
  1. #!/bin/bash
  2.  
  3. SAMBA=/path/to/samba/directory/to/share
  4. DEST=/path/to/linux/destination/directory
  5.  
  6. for i in `ls $SAMBA` ; do cp $SAMBA/$i $DEST ; chmod 644 $DEST/$i ; done

or this might work

Perl Syntax (Toggle Plain Text)
  1. #!/bin/bash
  2. SAMBA=/path/to/samba/directory/to/share
  3. DEST=/path/to/linux/destination/directory
  4.  
  5. cp $SAMBA/* $DEST
  6. chmod -R 644 $DEST

those are both over simplified, but with out more specifics. I don't really have any more to offer. Either of those scripts could be stuck in your /etc/cron.daily
Reputation Points: 10
Solved Threads: 17
Posting Whiz in Training
shanenin is offline Offline
217 posts
since May 2005
Jun 9th, 2005
0

Re: Save ME

Appreciate The Input, and you are correct, that would work..... not to be too much of a stickler though, this IS a Perl forum, and not a shell scripting forum. We have one of those here: http://www.daniweb.com/techtalkforums/forum113.html, that has a bunch of shell scripting posts.

Thank you.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Perl Forum Timeline: noobie asking for assistance with file parsing...
Next Thread in Perl Forum Timeline: finding a character string





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC