473,387 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

GPG problem with passphrase

ProcessStartInfo psi = new ProcessStartInfo("cmd.exe");

psi.CreateNoWindow = false;

psi.UseShellExecute = false;

psi.RedirectStandardInput = true;

psi.RedirectStandardOutput = true;

psi.RedirectStandardError = true;

psi.WorkingDirectory = "C:";

System.Diagnostics.Process process = System.Diagnostics.Process.Start(psi);

string sCommandLine = "echo test| gpg -es --passphrase-fd 0 --recipient jatinvmehta@gmail.com -o c:\test.gpg c:\test.txt";

process.StandardInput.WriteLine(sCommandLine);

process.StandardInput.Flush();

process.StandardInput.Close();

process.WaitForExit();

process.Close();



Same command run succesfully from commandline. I don't understand what is the problem.



Thanks in advance.
Mar 21 '08 #1
9 2168
balabaster
797 Expert 512MB
What error are you getting, what line of code is this failing at? If you don't tell us exactly what's wrong, there's no way anyone can help fix it...
Mar 21 '08 #2
What error are you getting, what line of code is this failing at? If you don't tell us exactly what's wrong, there's no way anyone can help fix it...
Hi Bala, i don't get any error. When i run the application, nothing happen and if i say
psi.CreateNoWindow = false;

It opens command window with following text

Reading passphrase from file descriptor 0

That's it.
Mar 21 '08 #3
balabaster
797 Expert 512MB
That's all you're telling it to do... if you take everything that's between the quotes from your command and paste it into the command window, what does it do?
Mar 21 '08 #4
That's all you're telling it to do... if you take everything that's between the quotes from your command and paste it into the command window, what does it do?
if i open command window by start --> run --> cmd and type following line

echo test| gpg -es --passphrase-fd 0 --recipient jatinvmehta@gmail.com -o c:\test.gpg c:\test.txt

I runs fine and create test.gpg.

Now, i have c# application and when i run same command by opening cmd.exe, it doesn't work.
Mar 21 '08 #5
balabaster
797 Expert 512MB
Did you mean to do something like this?
Expand|Select|Wrap|Line Numbers
  1. string sCommandLine = "echo test| gpg -es --passphrase-fd 0 --recipient jatinvmehta@gmail.com -o c:\test.gpg c:\test.txt";
  2. ProcessStartInfo psi = new ProcessStartInfo(sCommandLine);
  3. psi.CreateNoWindow = true;
  4. psi.UseShellExecute = false;
  5. psi.RedirectStandardOutput = true;
  6. psi.WorkingDirectory = "C:";
  7. System.Diagnostics.Process process = System.Diagnostics.Process.Start(psi);
  8. string output = process.StandardOutput.ReadToEnd();
  9. MessageBox.Show(output);
  10. process.WaitForExit();
  11. process.Close();
Mar 21 '08 #6
Did you mean to do something like this?
Expand|Select|Wrap|Line Numbers
  1. string sCommandLine = "echo test| gpg -es --passphrase-fd 0 --recipient jatinvmehta@gmail.com -o c:\test.gpg c:\test.txt";
  2. ProcessStartInfo psi = new ProcessStartInfo(sCommandLine);
  3. psi.CreateNoWindow = true;
  4. psi.UseShellExecute = false;
  5. psi.RedirectStandardOutput = true;
  6. psi.WorkingDirectory = "C:";
  7. System.Diagnostics.Process process = System.Diagnostics.Process.Start(psi);
  8. string output = process.StandardOutput.ReadToEnd();
  9. MessageBox.Show(output);
  10. process.WaitForExit();
  11. process.Close();
No, my c# application is window service. It takes file from directory encrypt it and store it on directory
Mar 21 '08 #7
balabaster
797 Expert 512MB
No, my c# application is window service. It takes file from directory encrypt it and store it on directory
Well...the code I posted will execute your command line...it dumps the output to a message box, but if you remove the two lines pertaining to the output itself, then you should find that the code actually executes the command line you specified.
Mar 21 '08 #8
Well...the code I posted will execute your command line...it dumps the output to a message box, but if you remove the two lines pertaining to the output itself, then you should find that the code actually executes the command line you specified.
Hi, ProcessStartInfo expect file name. If i run with your code, it stops at ReadToEnd() function for unlimited time.
Mar 21 '08 #9
balabaster
797 Expert 512MB
Expand|Select|Wrap|Line Numbers
  1. string sCommandLine = "echo test| gpg -es --passphrase-fd 0 --recipient jatinvmehta@gmail.com -o c:\test.gpg c:\test.txt";
  2. ProcessStartInfo psi = new ProcessStartInfo(sCommandLine);
These two lines of code assign a command to ProcessStartInfo. You don't need the ReadToEnd() because you're not actually outputting the response to screen. The command line creates the file so you don't need any other output.

Delete lines 8 and 9 of the code I posted if you're running as a Windows Service as it is irrelevant.
Mar 21 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jonas | last post by:
I have the following perl program witch i use to encrypt a password file with. In perl 5.6 this program works like a charm but when trying it on the RED HAT EL 3 platform (taroon) is doesnt...
1
by: Obi-Too | last post by:
I need to validate a password to only allow A-Z, a-z and 0-9. I thought this would work: function Validate() { var passphrase = document.all.challenge.value; var re = //; if...
34
by: jlocc | last post by:
Hi! I was wondering if someone can recommend a good encryption algorithm written in python. My goal is to combine two different numbers and encrypt them to create a new number that cann't be...
2
by: Alex | last post by:
Hi all, I'm having a problem with fsockopen function, I'm programming with php 4.3 and need to do an HTTP POST over secure socket, ssl, here's my code: $context = stream_context_create();...
3
by: raaj820 | last post by:
Hi guys, I am new to sql server 2000... I am having an excel attachment which i need to import into my database (i have done this part by using import/export wizard)... so now i am having a tbl in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.