I need help executing a bat file from asp.net 2.0 - asp.net

I have an web application using asp.net 2.0 and vb.net I wrote a bat file to use GPG to encryt a file and call it whithin asp.net shell(pathname & filename).
when I double click on the bat file from cmd windows it works fine but when I call it in the application everything command that I pass is executed perfectly except the gpg command. I make sure the user under which the application is running as all rights and privileges to run the commands I import, trust and verify all the keys and in fact the bat file works fine when double click on it but why it did successfully execute the GPG function. It did not return any error just did not encrypt any file
gpg -e --always-trust -r <> Filename
any help will be appreciated.
Thank you!

I had a similar problem:
C#.Net: Why is my Process.Start() hanging?
It seems that Microsoft, in all their infinite wisdom, has blocked batch files from being executed by IIS in Windows Server 2003. Brenden Tompkins has a work-around here:
http://codebetter.com/blogs/brendan.tompkins/archive/2004/05/13/13484.aspx

Have you tried fully qualifying the path to the gpg executable in your batch file?

Not sure how you are using 'shell()' but Process.Start is the way to go.

Related

Compile PL/SQL stored procedures in SQL developer from external files

I have a requirement where I have around 50 stored procedures saved in 50 different files with .pls extension in a windows directory. I have SQL Developer installed in the same machine. I want to compile all these stored procedures in SQL developer. Note - I don't want to execute, only want to compile. Please suggest a solution for this.
I have tried this but it didn't work.
Created a compile.sql file with contents below.
##"U:\Stored_Procedures\PRC_LOAD_TBL.pls";
exit;
Created a compile.bat file with contents below.
sqlplus -s -l <username>/<pswd>#<servicename>
#"U:\Stored_Procedures\Compile.sql" ;
Tried to run compile.bat batch file but it didn't work.
Also, I tried to run these from SQL Developer directly that didn't work either.
"Tried to run compile.bat batch file but it didn't work."
You tried to run a DOS batch file in SQL Developer? I think you're over-engineering this.
All you need to do is open your first script, compile.sql in SQL Developer and then click Run script (or press F5 function key).

TeamCity - Encrypt Connection Strings?

I've been fighting with TeamCity and cannot get this command to succeed. (It works fine manually.) I've tried many things and surprisingly Google wasn't much help. All I'm trying to do is encrypt the connection strings in my web.config file after a deploy.
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
ASPNET_REGIIS -pef "connectionStrings" "{mypath}"
Error: The configuration for physical path '{mypath}' cannot be opened.
I have it as the 2nd build step after my publish as a Command Line runner type.
I should also mention:
Yes, I'm selecting the folder the web.config is in and not the file itself.
Yes, the path is correct assuming it's supposed to be the one on the server. (C:\inetpub\mysite)
Most Importantly: I'm looking for a solution within TeamCity, not something manual or in my site's code.
Thanks!

Script runs in Unix but not in Informatica command task

My script ran successfully in Unix but not in a command task of an Informatica workflow. The permissions are fine, and the parameter file and variables have been declared in the workflow. Why is this happening?
Make sure that the machine you are running informatica on, is running in a unix box.
If it is on a windows machine, you will have to run the DOS equivalent command for your script.
Check whether informatica repository is pointing to same UNIX server, in which the script to executed from informatica is present.
I to faced same situation ,please check the propertied of script file make it as 755(CHMOD),It should work.
Regards
Rama
This could be a permission issue. If you are executing a shell command from Informatica, right click the file in SFTP and click on "Properties" (I am using Winscp).Give full permission to the file and now it should work.

Can I use a scp to download a file using shell script

Can I automate a download of a file from a system using scp(by entering the user id/password) and manipulate the file and upload it to the same place. If you have any idea of using scp in a shell script, pls do let me know
Thanks
Scp is ordinary command line uility in linux so it might be used directly. See this page for examples.
Yes you can automate that from a shell script pretty easily, but the question that remains is whether you want to input the password manually everytime you run the script or use ssh keys to accomplish authentication and achieve full automation.
Check this tutorial on using SCP.
use ssh-copy-id [the command varies by distro, but on Ubuntu it is ssh-copy-id]. here's how:
ssh-copy-id ~/.ssh/id_rsa.pub me#mysite.com this will install your public key to the remote host. it will not ask for your password if you do this! If you have no ~/.ssh/id_rsa.pub, then run ssh-keygen and accept all the default options [just press enter when it prompts for input].

How can I shell out of an ASP.NET page and execute a git command?

I want my ASP.NET page to shell out and execute git commands. I put the commands in a bat file which works:
REM cd to the git repo folder
cd c:\temp\mygitrepo
"c:\Program Files\Git\Bin\git.exe" show c090dc4b8b1b3512c1b5363c371e21d810d02f54 -- myfile.txt
If I run my .bat file from a cmd prompt, no problem.
If I run it using System.Diagnostics.Process.Start, I get this error:
RUNTIME_PREFIX requested, but prefix computation failed. Using static fallback
The error is coming from this git file: http://github.com/git/git/blob/master/exec_cmd.c
I use exactly the same technique to run svn.exe commands, no problem.
EDIT 1: From the thread here I've learned that msysgit installs some files in a location associated with the current user, me, instead of all users. The IIS web server is running under another user account. I tried copying some of the git files that caught my eye, like .gitconfig, to other users (in Documents and Settings). No luck. So, I have switched my focus to getting IIS to impersonate me when it launches the git command.
Is it actually an error, or is it just notifying you of a fallback? Based on the code linked, it appears that the command should still execute successfully, only using the static PREFIX rather than the RUNTIME_PREFIX.
If the command is indeed failing, you might want to make sure that any required environment variables are available when starting the process from .NET. You might also need to impersonate a different windows identity to run the command with proper permissions (I am assuming that the ASP.NET identity is restricted as much as possible.) The ProcessStartInfo object provides a few ways to configure the process, including the windows identity, the process verb, and environment variables. Make sure you are providing the proper context that your batch file requires before running it.

Resources