Perl for Unix & Windows


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl for Unix & Windows
# 8  
Old 07-08-2009
Hi,

With all of your input, i did intsall perl on windows from the activestate site.

My OS: Windows XP SP3

see below:
C:\Documents and Settings\>perl -v
This is perl, v5.10.0 built for MSWin32-x86-multi-thread

I did try the same unix script for windows and with modification of single quote to double quote.

the file change.txt

set CDIR=C:\

cd %CDIR%
perl -pi -e "
s|changeover|changeafter|g" tochange.txt
pause
exit

but when i run this file, it just hangs at
perl -pi -e "

line. Can anyone let me know, if any syntax changes on windows?
(As informed earlier, i could run the similar script on unix successfully).
thanks
# 9  
Old 08-10-2009
Quote:
Originally Posted by KevinADC
Change the single-quotes that surround the code to double-quotes when running on Windows.
Hi,
This file "config.prop" is located in various directories which are mapped as
u:
v:
n:
with the below code provided (from one of perl experts), i did try the same and could change the file in only one location.

while(<>){
chomp;
if ( /windowsdrivestocrawl=/){
w:/fdm9_84919_c347_2
}
print $_ ."\n";
}

The above is working perfectly, but only for the file located in current directory. (i have put in $file="config.prop" and it works fine if this is in current directory, but how to code for the directories as it changes - where iam stuck up!!)

Now this code needs to change this file in 3 different locations, with the directory and subsititution that changes for each directory. I will place this file in C: and then run the script so that it changes in all these 3 different locations (u, v, and n)
Example:
dir1:u:\psem\techart\agent
changefrom:n:/fdm9_84919_c347|j:/fdm9_84919_c347|w:/fdm9_84919_c347_2
changeto:w:/fdm9_84919_c347_2
The above is done using the code provided.


dir2:v:\psem\techart\agent
changefrom: n:/fdm9_84919_c347|j:/fdm9_84919_c347|w:/fdm9_84919_c347_2
changeto:n:/fdm9_84919_c347

dir3:n:\psem\techart\agent
changefrom: n:/fdm9_84919_c347|j:/fdm9_84919_c347|w:/fdm9_84919_c347_2
changeto:j:/fdm9_84919_c347

I tried with a variable
$dir and assigning it to other locations specified above.
It does not work.

Can you let me know how to do it? Any directions?
With just one code, i need to change the file in three different locations.
# 10  
Old 08-10-2009
Try starting it with
Code:
@volumes = ("u","v","n");
foreach $volume(@volumes){
   # When the program enters this loop the first time, $volume = "u"
   $directory = "$volume:\\psem\\techart\\agent";

   #you can test it with a print statement
   print "\$directory = $directory\n";

   # Do your substitutions for the file in $directory

   # When you are done, it will repeat the loop for the next two volumes
   # and then exit.
}


Last edited by avronius; 08-10-2009 at 01:29 PM.. Reason: Minor fixes
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Unix services for windows & Linux\Red Hat

I am not too familiar with linux, so please keep that in mind while reading this post. We have a few linux servers joined to the domain, and linux services for windows running. I have a user that can connect to one linux server, but not another. I ran the cat /etc/passwrd and noticed the user... (0 Replies)
Discussion started by: dcatcha
0 Replies

2. Solaris

Compatibility between Unix & Windows

Pl. let me know whether Sun Solaris Server (Unix OS) is compatible with Windows Server or Vise Versa. Can i update the data first in Windows Server and then copied it to Sun Solaris Server or Vise Versa. (1 Reply)
Discussion started by: seemaitri
1 Replies

3. AIX

sftp between Unix & windows

Guys, sftp between Unix & Windows I'd like to get good software or a way to how to configure sftp between ( windows to Unix ) and ( Unix to windows ) to be automatic login between the different operating systems without asking password .. Pls assist in this regard … (3 Replies)
Discussion started by: Mr.AIX
3 Replies

4. Shell Programming and Scripting

ftp from windows to unix using a perl script on unix machine

i need to ftp a file from windows to a unix machine by executing a sript(perl/shell/php) from that unix machine.i can also use HTML and javascript to build forms. (3 Replies)
Discussion started by: raksha.s
3 Replies

5. UNIX for Dummies Questions & Answers

FILE MANAGEMENT in WINDOWS & UNIX

Hi, I am a new member here. I am in my final year of engineering in Computer & Information Systems. Wanted to know, how file management is done in both windows and unix. Kindly, tell me anyone who knows it in detail, or has any links regarding it. Thanks (1 Reply)
Discussion started by: farazcis
1 Replies

6. UNIX for Dummies Questions & Answers

Networking unix & windows

I have very basic question: I have 2 windows sytem & 1 Unix system & wanted to put all three system into one network to each other. what kind of other hardware I need? like cable , router? can anybody tell me the configuration? like how to connect to external hardware to put into network? ... (9 Replies)
Discussion started by: kar1
9 Replies

7. UNIX for Dummies Questions & Answers

Different Format in Unix & Windows

I used the following commands to store the discription of "sed" into a unix file: man sed > sed.txt But, after I download the file "sed.txt" to a Windows XP system, the file can not be displayed correctly. How to change the format of a Unix file to a Windows one? (5 Replies)
Discussion started by: endeavour1985
5 Replies

8. IP Networking

UNIX OS & Windows XP

Hello, Can someone please tell me if it is possible to install a Unix Os on a system that already has a Windows XP? If so, how do i go about it doing it?: (6 Replies)
Discussion started by: Ike
6 Replies

9. UNIX for Advanced & Expert Users

Connectivity B/w Unix & windows

i want to install ScO UNIX 5.1 in a windows 98 system. i want it as a DUAL BOOT system. can i doit? If yes How. and also i want to network unix with my clients. is it poosible to network both unix & windows thru a single network card. if yes how? also i wanted to know that thru a switch can i... (3 Replies)
Discussion started by: jigs
3 Replies

10. UNIX for Dummies Questions & Answers

seperate hard drive for unix & x windows

thanks for your help, i didnt realise you could download the operating system from sun.com:D Ive just had a new hard drive installed 20 GIG for unix and x windows. How can i connect this hard drive for unix and x windows only? and are there any helpful tutorials for starters?? Many thanks (4 Replies)
Discussion started by: jeffersno1
4 Replies
Login or Register to Ask a Question