Perl-extraction using windows cmd


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl-extraction using windows cmd
# 1  
Old 09-04-2014
Perl-extraction using windows cmd

Hi, I need to extract
HTML Code:
Password expires
from the output of windows command
Code:
print `net user %USERNAME% /domain`;

in perl. So i want to redirect the output of this win-cmd to a file and try extracting
HTML Code:
Password expires
along with its value. i'm trying with this code but getting errors.
Code:
#!usr/bin/perl
use warnings;
use strict;
print `net user %USERNAME% /domain` >out.txt;

Requesting help.
# 2  
Old 09-04-2014
The first thing I noticed was the wrong shebang/hashbang line, it should be #!/usr/bin/perl, but since you are running your script on Windows, it is ignored anyway.

Regarding your issue with output redirection, I suggest to try this:
Code:
print `net user %USERNAME% /domain >out.txt`;

Let me know if that worked.

Regarding the extraction part, I suggest doing it in Perl on-the-fly, without redirecting it to outfile first.
If you need help with this, you'll need to post a full sample output of the mentioned net user command.

Hope this helps.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Listing multiple files in windows cmd

i have multiple files like how to do list files from new_30 to new_50 i have tried this command but it wont work dir new*{30-50}.txt my exact requirement is to get line count of these files the command which work is FOR %i IN (new*.txt) DO find %i /c /v "" but at the... (1 Reply)
Discussion started by: sagar_1986
1 Replies

2. Shell Programming and Scripting

Perl open(CMD, "cmd |"); buffering problem..

Hello, There's a third-party application's command that shows the application's status like "tail -f verybusy.log". When use the command, the output comes every 1-sec. but when it goes in a script below the output comes every 8-sec...What is the problem and how can I fix it? open(CMD,... (2 Replies)
Discussion started by: Shawn, Lee
2 Replies

3. Windows & DOS: Issues & Discussions

How to know machine details in windows through cmd

Hi, I want to print machine details in windows. In UNIX it is easily available by the command uname -X Is there any command like this in windows to get those details.. can anybody help me on this.. Thanks in advance. ~arup (1 Reply)
Discussion started by: arup1980
1 Replies

4. Shell Programming and Scripting

Use Unix shell script to open Windows command prompt (cmd)

Hello, I work on Windows and I use Putty to access a remote UNIX server. I am trying to build a shell script that will have as main task to open the Windows command prompt (cmd) and run some Windows commands thereafter. The commands are actually file transfer commands that will download a file... (14 Replies)
Discussion started by: rookie2785
14 Replies

5. UNIX for Dummies Questions & Answers

Need help configuring Active Perl on Windows Vista.: Perl Scripting on Windows

Hi All, Need help configuring Active Perl on Windows Vista. I am trying to install Active Perl on Windows Vista. The version of Active Perl i am trying to install is : ActivePerl 5.10.1 Build 1006 After installing it through cmd, When i try to run perl -v to check the version, i get the... (2 Replies)
Discussion started by: Vabiosis
2 Replies

6. Shell Programming and Scripting

Function extraction in PERL

the log contains mathematical operation as follows fm_void_mathematics : PCM_OP_MATHS input function PIN_FLD_NUM1 INT 1 PIN_FLD_NUM2 INT 2 PIN_FLD_RESULTS int PIN_FLD_OUT INT * D Wed Sep 16 05:40:22 2009 solaris_testing fm_void_add : PIN_FLD_SUM int 3 D Wed Sep 16 05:40:22 2009... (1 Reply)
Discussion started by: vkca
1 Replies

7. Shell Programming and Scripting

Perl function extraction

The log file reads as follows. D function_add() ADD input data 1021214 0 VAR1 STR 10 0 VAR2 STR 20 0 VAR3 STR 1 SUM=VAR1+VAR2 D function_add() ADD output data 1021267 0 DISPLAY SUM D function_sub() SUB input data 1021214 0 VAR1 STR 10 0 VAR2 STR 20 0 VAR3 STR 1 sub=VAR1-VAR2 D... (2 Replies)
Discussion started by: vkca
2 Replies

8. Shell Programming and Scripting

String Extraction in Perl

I have a string stored in a variable. For instance, $str = " Opcode called is : CM_OP_xxx " where xxx changes dynamically and can be either LOGIN or SEARCH..... depends on runtime. For example : $str = " Opcode called is : CM_OP_SEARCH " $str = " Opcode called is : CM_OP_LOGIN " I... (3 Replies)
Discussion started by: vkca
3 Replies

9. Shell Programming and Scripting

self extraction zip for windows

Hi I want to create self extraction archive file(exe) that should support in windows with out any zip software. I know pkzip does it. But this is licensed software. Is there any command that creates self extraction exe file for free in solaries 5.10 Similar to command. pkzipc -add -max... (2 Replies)
Discussion started by: svenkatareddy
2 Replies

10. Shell Programming and Scripting

metapattern extraction in PERL

Hi, I want to extract some part of a pattern that matches my requirement in a string with PERL. A case in point is a string like: $eqtst="abh nmae res = 10 s abh nmae req = 10 s"; from which I want the words preceding the "=" symbol. Previously I was assured that there would be only 2 such... (4 Replies)
Discussion started by: Abhishek Ghose
4 Replies
Login or Register to Ask a Question