How to dynamically create user name in perl and move the files?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to dynamically create user name in perl and move the files?
# 1  
Old 07-16-2010
How to dynamically create user name in perl and move the files?

Hi,

I have two problems in which i have stuck up.

a) To move the files and copy back.
b) To create user dynamically.

Question 1:

I have to move the files to some other directory and copy it when all the process is done.

I have the code like this:

Code:
$file = "/home/data/file1.txt";
$file1 = "/home/data/disk/";

system("mv $file $file1");

The problem here is i am able to move the files but again coping back is not happening. The entire directory is getting replaced.

How can i move the files from one directory to another and again copy it back to same directory?

Question 2:

I have to create a dummy user name dynamically how can i create dummy username dynamically. At present i am a root user.
How can i create dummy user name dynamically?

After creating dynamically i need to copy to this user created login and create the directory and move this file1.txt.

How can i do this in perl?

Regards
# 2  
Old 07-16-2010
Why do you want to mv files from one dir to another and then again copy them back ? You could instead just copy them in the first place. Perhaps explaining what you're trying to do will help us help you better ?
# 3  
Old 07-16-2010
Code:
$file = "/home/data/file1.txt";
$file1 = "/home/data/disk/";

$file is pointed to file, but $file1 is point to a folder.

Code:
$file = "/home/data/file1.txt";
$file1 = "/home/data/disk/file1.txt";
system("mv $file $file1");
system("mv $file1 $file");

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

List files with date, create directory, move to the created directory

Hi all, i have a folder, with tons of files containing as following, on /my/folder/jobs/ some_name_2016-01-17-22-38-58_some name_0_0.zip.done some_name_2016-01-17-22-40-30_some name_0_0.zip.done some_name_2016-01-17-22-48-50_some name_0_0.zip.done and these can be lots of similar files,... (6 Replies)
Discussion started by: charli1
6 Replies

2. Linux

Create folder by script & move files in it

Hi Team, I have over 1 lakh pdf files. I want to create folders like Disk-1, Disk-2 ..... & want to move 3000 pdfs per folder. Can i do it by script? Please help me. Thanks & Regards Parag Nehete (4 Replies)
Discussion started by: paragnehete
4 Replies

3. Shell Programming and Scripting

every time user input create array perl

Hi, How to create array every time user input and store user input and display all array print " Enter input " my @input = split(' ', $input) chmop($input = <STDIN>; foreach ($input) { @array= @input; } print @array"\n"; (1 Reply)
Discussion started by: guidely
1 Replies

4. Shell Programming and Scripting

how to create the files dynamically in c shell script

how can i CREATE a txt file dynamically in c shell: for instance: #! /bin/csh for each i (*) cat>file$i.txt for each j do .... (1 Reply)
Discussion started by: jdsignature88
1 Replies

5. Shell Programming and Scripting

How to create hash dynamically in perl?

Hi, I have one file name file.txt It has the following contents: #File Contents StartTime,EndTime,COUNTER1,COUNTER2,COUNTER3 12:13,12:14,0,1,0 The output should be like this: StartTime: 12:13 ENDTIME: 12:14 (2 Replies)
Discussion started by: vanitham
2 Replies

6. Shell Programming and Scripting

Dynamically create arrays

I have a bash challenge. I have several virtualization hosts for which I need to collect VM information. I need to dynamically create an array for each host. The contents of the array should be the list VMs running on the host. Here's the logic; I just need someone to help me with the details:... (0 Replies)
Discussion started by: EdgarTorres
0 Replies

7. Shell Programming and Scripting

Need to dynamically create a file

I'm trying to write a script that generates a file of varying size filled with random text and am having some difficulties. The major problems are that I'm limited to csh and a lot of the systems I have to run this on don't have a /dev/random (so a wrapper around the dd if=/dev/random or dd... (14 Replies)
Discussion started by: stareja
14 Replies

8. Shell Programming and Scripting

Perl script to move files not in use

I need to write a script to move files only when they are not in use. I have a rudementry bash script for Linux but i need a perl script so it will work on Linux and hpux. Oracle writes files to a directory called /data and the files there are moved every 5 minutes to a new home. But i need to... (1 Reply)
Discussion started by: insania
1 Replies

9. Shell Programming and Scripting

create an user in perl

hi friends, i want to create an new user in my home directory , only just for checking. if it is possible, please help me. thanks (1 Reply)
Discussion started by: praneshbmishra
1 Replies

10. UNIX for Advanced & Expert Users

Other than root user .Normal user is unable to create files

Hi all, I am using Sun Solaris 9 .In this system normal users unable to create files from the command line.I added these users in bin,adm and even root group i found them unable to create a file. (1 Reply)
Discussion started by: mallesh
1 Replies
Login or Register to Ask a Question