954,523 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Save ME

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.

anthony05
Newbie Poster
7 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

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.

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

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.

anthony05
Newbie Poster
7 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

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?)....

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

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

anthony05
Newbie Poster
7 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

Ok, What Directory on the unix box is the windows share mounted on? (what is the unix path to the samba share)?

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

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.

anthony05
Newbie Poster
7 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

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?

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

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

#!/bin/bash

SAMBA=/path/to/samba/directory/to/share
DEST=/path/to/linux/destination/directory

for i in `ls $SAMBA` ; do cp $SAMBA/$i $DEST ; chmod  644 $DEST/$i ; done


or this might work

#!/bin/bash
SAMBA=/path/to/samba/directory/to/share
DEST=/path/to/linux/destination/directory

cp $SAMBA/* $DEST
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

shanenin
Posting Whiz in Training
217 posts since May 2005
Reputation Points: 10
Solved Threads: 17
 

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.

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

To be honest When I placed that answer I thought I was answering his post that he left in th linux shell scripting forum(he posted in both areas). After making the post I realized it was in the perl section. I thought I amended the post to clear up my mistake, I must have just previewed it , but for got to make the changes final.

shanenin
Posting Whiz in Training
217 posts since May 2005
Reputation Points: 10
Solved Threads: 17
 

Hello Comatose & to everybody,

Ok Comatose i agree with you that i can see files in them, how to do chmod.
Will you please tell me how to do vice versa copy linux files (sub-folder) to windows.
Help will be highly appreciated.

anthony05
Newbie Poster
7 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You