您好,我有一个程序,要求我将PATH环境变量设置为指向JRE版本1.5,因为我需要通过命令提示符访问该程序.那么关于如何做到这一点的任何想法?
我有一个C#控制台程序,其主要功能应该使用户grep行/列来自日志文本文件。
用户希望在文本文件中的一个示例中重复一组从特定日期等开始的所有相关行。“星期二2004年8月3日22:58:34”到“星期三2004年8月4日00:56:48”。因此,在处理之后,程序将输出两个日期之间在日志文本文件中找到的所有数据。
有人可以提供一些我可以用来grep或创建过滤器以从文件中检索必要的文本/数据的代码的建议吗?谢谢!
C#程序文件:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
namespace Testing
{
class Analysis
{
static void Main()
{
// Read the file lines into a string array.
string[] lines = System.IO.File.ReadAllLines(@"C:\Test\ntfs.txt");
System.Console.WriteLine("Analyzing ntfs.txt:");
foreach (string line in lines)
{
Console.WriteLine("\t" + line);
// ***Trying to filter/grep out dates, file size, etc****
if (lines = "Sun Nov 19 2000")
{
Console.WriteLine("Print entire line");
}
}
// Keep the console window open in debug …Run Code Online (Sandbox Code Playgroud) 我有一个程序能够使用标记化检索日志文本文件的部分/部分时间.
该程序的主要目的是检索时间部分然后继续将字符串转换为DateTime格式,然后可以将其用作时间范围时间轴函数的一部分.
但是,在将时间转换为DateTime时,系统会将结果输出到"23/11/2010 9:31:00 PM",这会将时间正确转换为12小时格式,但会使用日期功能.
因此问题是如何只转换时间和NOT输出或处理日期.如何将时间转换为24小时格式为HH:MM:SS?
请告知代码.谢谢!
class Program
{
static void Main(string[] args)
{
//System.Collections.Generic.IEnumerable<String> lines = File.ReadLines("C:\\Test\\ntfs2.txt");
String value = "Thu Mar 02 1995 21:31:00,2245107,m...,r/rrwxrwxrwx,0,0,8349-128-3,C:/Program Files/AccessData/AccessData Forensic Toolkit/Program/wordnet/Adj.dat";
//foreach (String r in lines)
//{
String[] token = value.Split(',');
String[] datetime = token[0].Split(' ');
String timeText = datetime[4]; // The String array contans 21:31:00
DateTime time = Convert.ToDateTime(timeText); // Converts only the time
Console.WriteLine(time);
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个程序,它利用第三方命令行工具生成日志.第三方将其所有输出生成到STDOUT,然后用户必须使用该" > test.txt"命令来保存文件.
但是,程序会以某种方式生成一定数量的报告,但不会生成整个报告.这是通过使用命令进行测试
C:\Test\ftk\ripxp>ripxp.exe -r C:\test\ftk\ntuser.dat -d "C:\System Volume\_rest
ore{BB12863B-2C77-46C9-BCDA-1810E52F1089}" -p runmru > C:\test\test05.txt
在命令行控制台上工作,并在程序上只部分工作.
错误被缩小到参数错误或文件保存错误部分(streamReader).因此,错误可能是由于未正确保存STDOUT.
因此,有人可以提供代码建议吗?谢谢!
第三方工具的论点(2008 H. Carvey):
RipXP v.20081001 - CLI RegRipper tool
RipXP [-r Reg hive file] [-p plugin module][-d RP dir][-lgh]
Parse Windows Registry files, using either a single module from the plugins folder.
Then parse all corresponding hive files from the XP Restore Points (extracted from
image) using the same plugin.
-r Reg hive file...Registry hive file to parse
-g ................Guess …Run Code Online (Sandbox Code Playgroud) 有没有人知道我在linux red hat 5中安装后.htaccess文件位于何处?
我有一个简短的程序,它将字符串转换为简单字符串的日期和时间格式.
但是,由于字符串的顺序,系统似乎无法将字符串转换为日期时间格式.应该转换的字符串就像一个例子:"Thu Dec 9 05:12:42 2010"
该方法Convert.ToDateTime已被使用但不起作用.
有人可以告知代码吗?谢谢!
String re = "Thu Dec 9 05:12:42 2010";
DateTime time = Convert.ToDateTime(re);
Console.WriteLine(time.ToString("dddd, dd MMMM yyyy HH:mm:ss"));
Run Code Online (Sandbox Code Playgroud) 我有一个程序,它将不规则的日期和时间字符串转换为系统DateTime.
但是,由于系统无法识别不规则字符串,因此.ParseExact,toDateTime和TryParse方法无效.
程序需要转换的日期时间字符串只有两种:
Thu Dec 9 05:12:42 2010
Mon Dec 13 06:45:58 2010
Run Code Online (Sandbox Code Playgroud)
请注意,单个日期有一个双倍间距,我使用.replace方法将单个日期转换为Thu Dec 09 05:12:42 2010.
有人可以告知代码吗?谢谢!
代码:
String rb = re.Replace(" ", " 0");
DateTime time = DateTime.ParseExact(rb, "ddd MMM dd hh:mm:ss yyyy", CultureInfo.CurrentCulture);
Console.WriteLine(time.ToString("dddd, dd MMMM yyyy HH:mm:ss"));
Run Code Online (Sandbox Code Playgroud) 我有一个计算应用程序,我需要验证字段,以检查输入的值是否是数字而不是字母数字.我对这些代码有一些想法.
如果我做错了什么或看起来像菜鸟,请指导我,因为这是我第一次尝试Swing.
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
String text1 = jTextField1.getText(); // TODO add your handling code here:
}
private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {
String text2 = jTextField2.getText(); // TODO add your handling code here:
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
if (text1 and text2 != <numeric number>){
JOptionPane.showConfirmDialog(null, "Please enter numbers only", "naughty", JOptionPane.CANCEL_OPTION);
}
// First we define float variables.
float num1, num2, result;
// We have to parse the text to a type float.
num1 = Float.parseFloat(jTextField1.getText()); …Run Code Online (Sandbox Code Playgroud) 有没有办法给文本下划线是一个perl 输出脚本?我已经阅读了多个来源,但脚本中的文本不能加下划线。
错误输出:全局符号“$finalAddition”需要在 C:\Documents and Settings\PCS\Desktop\Perl Scripts\script.pl 第 7 行的显式包名称。
脚本代码:
#!/usr/bin/perl
use warnings;
use strict;
use Term::ANSIColor;
$finalAddition = 8;
print "\n\nThe Final Number after addtion would be ".coloured($finalAddition, 'bold
underline');
Run Code Online (Sandbox Code Playgroud)
请就此提出一些建议。谢谢。
我有一个关于从文本日志文件转换的数组的读取序列的问题.
由于在第一行[0]中的过程中我不需要读取文件头,是否有任何方法可以跳过读取行[0]并首先开始读取行[1]?
该程序利用foreach循环读取数组.并且有一种标记化方法,因此标记化需要foreach循环来重新调整数组的String格式.
请通过建议代码帮助!谢谢!
程序代码:
class Program
{
static void Main(string[] args)
{
System.Collections.Generic.IEnumerable<String> lines = File.ReadLines("C:\\syscrawl\\ntfs3.txt");
foreach (String r in lines) //Start reading from lines[1] first instead?
{
String[] token = r.Split(',');
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果你需要日志文本文件,这里是一个例子:
Date,Size,Type,Mode,UID,GID,Meta,File Name // Lines[0]
Sun Jul 22 2001 02:37:46,73882,...b,r/rrwxrwxrwx,0,0,516-128-3,C:/WINDOWS/Help/digiras.chm // Lines [1]
Sun Jul 22 2001 02:44:18,10483,...b,r/rrwxrwxrwx,0,0,480-128-3,C:/WINDOWS/Help/cyycoins.chm
Sun Jul 22 2001 02:45:32,10743,...b,r/rrwxrwxrwx,0,0,482-128-3,C:/WINDOWS/Help/cyzcoins.chm
Sun Jul 22 2001 04:26:14,174020,...b,r/rrwxrwxrwx,0,0,798-128-3,C:/WINDOWS/system32/spool/drivers/color/kodak_dc.icm
Run Code Online (Sandbox Code Playgroud) 我有一个使用Perl 5.8在Linux平台上构建的Perl脚本.但是现在我尝试在具有相同Perl版本的Windows平台命令提示符下运行Perl脚本.
我正在使用这个命令,perl rgex.pl但它给了我一大堆错误,在我看来它已经在脚本本身已经解决了.奇怪的是我能够运行另一个Perl脚本而不会出现由打印,输入等简单函数组成的问题.
代码:
#!/usr/bin/perl
use warnings;
use strict;
use Term::ANSIColor;
my $file = "C:\Documents and Settings\Desktop\logfiles.log";
open LOG, $file or die "The file $file has the error of:\n => $!";
my @lines = <LOG>;
close (LOG);
my $varchar = 0;
foreach my $line ( @lines ) {
if ( $line =~ m/PLLog/ )
{
print("\n\n\n");
my $coloredText = colored($varchar, 'bold underline red');
print colored ("POS :: $coloredText\n\n", 'bold underline red');
$varchar ++;
}
print( $line ); …Run Code Online (Sandbox Code Playgroud)