Run os commands with sql

dear all,
is it possible to run os commands with sql commands as follows :
SQL> ALTER system kill session '1764,60569'; ! kill -9 12151
2 /
ALTER system kill session '1764,60569'; ! kill -9 12151
ERROR at line 1:
ORA-00911: invalid character
kai
os version : solaris 5.10.. db : 10.2.0.4.0

Kais,
What exact error are you getting running this script and what's OS (is it linux RH?? If you can post errors on running this script, that will be helpful. I tested on both cygwin (my desktop) and liunx box but you can change as needed) and to kill process from script you can use
echo `kill -9 pid`
Hope this helps
#!/bin/bash
typeset username=$1
function readSqlstmt {
typeset stmt=$1
echo "
set feedback off
set verify off
set heading off
set pagesize 0
whenever sqlerror exit 1
whenever oserror exit 2
$stmt;
exit
" | sqlplus -S '/as sysdba >> test.log
function killpid {
killpidsql=killpid.sql
sqlplus -s '/as sysdba' << ENDOFSQL >> test.log
whenever sqlerror exit 1
whenever oserror exit 2
SET pagesize 0
SET verify off
SET feedback off
SPOOL ${killpidsql}
SELECT 'ALTER system kill session ''' || s.sid || ',' || s.serial# || ''';'
FROM v\$session s, v\$process p
WHERE s.paddr = p.addr AND s.status = 'INACTIVE';
SPOOL OFF
@${killpidsql}
ENDOFSQL
killpid
readSqlstmt "SELECT p.spid FROM v\$session s, v\$process p WHERE s.paddr = p.addr AND s.status = 'INACTIVE'" | while read u
do
     #echo "kill -9" $u >> test.log
     echo "Killing inactive oracle process..."
echo `kill -9 $u`
done

Similar Messages

  • How to run Unix command with Pipe ( | )?

    Dear Friends,
    I have to execute the below unix command through java program.
    *ps -ewwo pid,args | grep -E "abc.sh|xyz.jar" | gawk '{ print $1 }' | wc -l*
    My code to execute this command is,
    Runtime run = Runtime.getRuntime();
    File workDir = new File("/root/sat");
    String psCmd = "ps -ewwo pid,args | grep -E \"abc.sh|xyz.jar \" | gawk '{ print $1 }' | wc -l";
    Process process = run.exec(psCmd, null, workDir);
              String line;
              int i = process.waitFor() ;
              if(i == 0) {
              BufferedReader buf = new BufferedReader( new InputStreamReader( process.getInputStream() ) ) ;
              while ( ( line = buf.readLine() ) != null )
                   System.out.println("Line - ["+line+"]") ;
              } else {
                   BufferedReader stdErr = new BufferedReader(new InputStreamReader(process.getErrorStream()));
                   // read the output from the command
                   while ((line = stdErr.readLine()) != null) {
                   System.out.println(line);
                   }When i execute this command, i'm getting output as,
    ERROR: Garbage option.
    When i analyse the above error, i found that, the PIPE ( | ) command is not supported through java.
    Could anyone please help me how to execute the above unix command (with | ) in java?
    Thanks in advance,
    Sathish

    The pipe has to be interpreted by a shell so you need
    String[] psCmd =
        "sh",
        "-c"
        "ps -ewwo pid,args | grep -E \"abc.sh|xyz.jar \" | gawk '{ print $1 }' | wc -l"
    Process process = run.exec(psCmd, null, workDir);You should also read, re-read and then implement the recommendations in the 4 sections of http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html .

  • Running OS Command From SQL

    Hellow,
    Can Any Anyone tell me how to run an Operating System Command From SQL ???
    Or From Developer 6i ??
    Regards
    Tariq

    Use Host command

  • Need to run netsh command with elevated previledges

    Hi Team,
    I am running an script with netsh command for to enable file & print sharing module and that to only for an domain profile.
    But when i try to call this command through VB script, it asks me to run that in elevated previledges.
    PLease help me how do i achieve that, or is there any feasibility to invoke same in bat file itself, please let me know.
    Regards,
    Deepak Sharma.

    Here are couple of URL that might help you : 
    http://stackoverflow.com/questions/17466681/how-to-run-vbs-as-administrator-from-vbs
    http://social.technet.microsoft.com/Forums/scriptcenter/en-US/310e57f9-2367-4293-9f97-53d0e077aacc/vb-script-to-run-a-batch-script-as-admin?forum=ITCG
    http://www.server-world.info/en/note?os=Other&p=vbs
    Arnav Sharma | http://arnavsharma.net/ Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading
    the thread.

  • Running interactive command with Runtime.exec

    I'm trying to run a command via the Runtime.exec interface.
    Occasionally, the command needs to prompt for additional information. The response depends on the specific configuration, however, the command returns a list of options and then waits for a response.
    However, when the command waits for the response, my Java app hangs.
    After I call Runtime.exec, I create 2 threads to consume the contents of stderr and stdout. I then start them and call proc.waitFor()
    I would expect to see the output of the command in the stdout stream even though the command hasn't exited. I had hoped to parse the output to determine the necessary response. However, the calls to read the contents of the stdout and stderr streams block and I never see any output.
    How can I get access to the contents of those streams while the command is still running? Is this supported through the Runtime.exec interface?
    Thanks,
    Shawn

    This article should help:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • How can you run a command with elevated rights on a remote server with invoke-command ?

    I am trying to run a script on a remote server with invoke-command.  The script is starting and is running fine, but the problem is that it should be running with elevated rights on the remote server.  On the server where I start the invoke-command, my account has the necessary rights.
    The server were I launch the invoke-command is a W2K8 R2.  The remote box is a W2K3 with powershell v2.0 installed.
    When I launch the script on the remote-box from the command line, I don't get the access denied's.
    Is there a way to do this ?
    Thanks in advance

    The script that I want to run is to install the windows updates.  I get an access denied on the download of the updates.
    When I execute the script on an W2K8 box, (not remotely) and I run it with non-elevated rights, I get the same error.
    The script is running fine when it is launched on W2K3 box locally with a domain account that has local admin rights, or on a W2K8 R2 server with a domain account that has local admin rights, but with elevated rights.
    Thanks in advance for your help.
    #=== start script ====
    param($installOption="TESTINSTALL",$rebootOption="NOREBOOT")
    Function Show-Help
    Write-Host ""
    Write-Host "SCRIPT: $scriptName <installOption> <RebootOption>"
    Write-Host ""
    Write-Host "DESCRIPTION: Installatie van WSUS updates op de lokale server"
    Write-Host ""
    Write-Host "PARAMETERS"
    Write-Host " -installOption <[INSTALL|TESTINSTALL]>"
    Write-Host " -rebootOption <[REBOOT|NOREBOOT|REBOOT_IF_UPDATED]>"
    Write-Host ""
    Write-Host "EXAMPLE:"
    Write-Host "$ScriptName -installOption INSTALL -rebootOption REBOOT_IF_UPDATED"
    Write-Host "$ScriptNAme INSTALL NOREBOOT"
    Write-Host ""
    Write-Host "Indien beide parameter weggelaten worden zijn de defaultwaarden :"
    Write-Host " installOption=TESTINSTALL "
    Write-Host " RebootOption=NOREBOOT"
    Write-Host ""
    Exit
    #Include alle globale variablen
    $CEIF_WIN_PATH = (get-content env:CEIF_WIN_PATH)
    $includeFile=$CEIF_WIN_PATH + "\Scripts\include_win.ps1"
    . $includeFile
    #initialiseer error count
    $errcnt=0
    $scriptName=$MyInvocation.MyCommand.Name
    #argumenten controleren
    $arrInstallOption= "TESTINSTALL", "INSTALL" # Mandatory variable with predefined values
    If (!($arrInstallOption –contains $installOption)){ Show-Help }
    $arrRebootOption = "REBOOT", "NOREBOOT","REBOOT_IF_UPDATED" # Mandatory variable with predefined values
    If (!($arrRebootOption –contains $rebootOption)){ Show-Help }
    #Logfile opbouwen
    $logfile = get-logfileName($MyInvocation.MyCommand.Name)
    Log-scriptStart $MyInvocation.MyCommand.Name $logfile
    function Get-WIAStatusValue($value)
    switch -exact ($value)
    0 {"NotStarted"}
    1 {"InProgress"}
    2 {"Succeeded"}
    3 {"SucceededWithErrors"}
    4 {"Failed"}
    5 {"Aborted"}
    function boot-server()
    if ($installOption -eq "TESTINSTALL")
    logger "TESTINSTALL : - Reboot local Server" $logfile
    else
    logger " - Reboot local Server" $logfile
    $thisServer = gwmi win32_operatingsystem
    $thisServer.psbase.Scope.Options.EnablePrivileges = $true
    $thisServer.Reboot()
    $logmsg="Install option = " + $installOption + ", RebootOption = $rebootOption"
    logger "$logmsg" $logfile
    logger "" $logfile
    logger " - Creating WU COM object" $logfile
    $UpdateSession = New-Object -ComObject Microsoft.Update.Session
    $UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
    logger " - Searching for Updates" $logfile
    $SearchResult = $UpdateSearcher.Search("IsAssigned=1 and IsHidden=0 and IsInstalled=0")
    logger " - Found [$($SearchResult.Updates.count)] Updates to Download and install" $logfile
    $Updates=$($SearchResult.Updates.count)
    logger "" $logfile
    foreach($Update in $SearchResult.Updates)
    if ($Update.EulaAccepted -eq 0)
    $Update.AcceptEula()
    # Add Update to Collection
    $UpdatesCollection = New-Object -ComObject Microsoft.Update.UpdateColl
    $UpdatesCollection.Add($Update) | out-null
    if ($installOption -eq "TESTINSTALL")
    else
    # Download
    logger " + Downloading Update $($Update.Title)" $logfile
    $UpdatesDownloader = $UpdateSession.CreateUpdateDownloader()
    $UpdatesDownloader.Updates = $UpdatesCollection
    $DownloadResult = $UpdatesDownloader.Download()
    $Message = " - Download {0}" -f (Get-WIAStatusValue $DownloadResult.ResultCode)
    if ($DownloadResult.ResultCode -eq 4 )
    { $errcnt = 1 }
    logger $message $logfile
    # Install
    logger " - Installing Update" $logfile
    $UpdatesInstaller = $UpdateSession.CreateUpdateInstaller()
    $UpdatesInstaller.Updates = $UpdatesCollection
    $InstallResult = $UpdatesInstaller.Install()
    $Message = " - Install {0}" -f (Get-WIAStatusValue $InstallResult.ResultCode)
    if ($InstallResult.ResultCode -eq 4 )
    { $errcnt = 1 }
    logger $message $logfile
    logger "" $logfile
    #Indien er een fout gebeurde tijdens download/installatie -> stuur mail naar windowsteam
    if ( $errcnt -gt 0 )
    logger " - Fout tijdens de uitvoering van script -> send mail" $logfile
    $mailSubject=$MyInvocation.MyCommand.Name
    $msg = new-object Net.Mail.MailMessage
    $att = new-object Net.Mail.Attachment($logfile)
    $smtp = new-object Net.Mail.SmtpClient($smtpServer)
    $msg.From = $mailFrom
    $msg.To.Add($mailTo)
    $msg.Subject = $mailSubject
    $msg.Body = “Meer details in attachement”
    $msg.Attachments.Add($att)
    $smtp.Send($msg)
    #Moet de server herstart worden ?
    if ($rebootOption -eq "REBOOT_IF_UPDATED" )
    if ($Updates -gt 0)
    #Reboot the server when updates are installed
    boot-server
    elseif ($rebootOption -eq "REBOOT")
    #reboot the server always
    boot-server
    else
    #Do not reboot the server
    logger "Do not reboot the server" $logfile
    Log-scriptEnd $MyInvocation.MyCommand.Name $logfile
    exit 0

  • User Defined Activity: Run OS Command with OS parameters

    OS: OELR5 U3 x64
    DB: 11.1.0.7
    OWB: 11R1
    I would like to be able to run an os command from a user defined activity within a process flow. I am trying to make use of VMWare's vmrun to control a virtual machine. From the OS command line I enter:
    /usr/bin/vmrun -T server -h https://server:port/sdk -u user -p userpassword -gu guest -gp guestpassword runProgramInGuest "[standard] VM/Virtual Machine.vmx" -activeWindow -interactive "c:\path_to_program\program.exe" /switch
    How many I duplicate this OS command from within a user defined activity in a process flow?
    I create a user defined activity:
    COMMAND: /usr/bin/vmrun
    PARAMETER_LIST:
    RESULT_CODE:
    SCRIPT: -T server -h https://server:port/sdk -u user -p userpassword -gu guest -gp guestpassword runProgramInGuest "[standard] VM/Virtual Machine.vmx" -activeWindow -interactive "c:\path_to_program\program.exe" /switch
    SUCCESS_THRESHOLD: 0
    The process runs without error in the log, but the os command is not being run.
    I tried again with:
    COMMAND: /usr/bin/vmrun
    PARAMETER_LIST: ?-T?server?-h?https://server:port/sdk?-u?user?-p userpassword?-gu?guest?-gp guestpassword?runProgramInGuest "[standard] VM/Virtual Machine.vmx"?-activeWindow?-interactive?"c:\path_to_program\program.exe"?/switch?
    RESULT_CODE:
    SCRIPT:
    SUCCESS_THRESHOLD: 0
    with the same result.
    And I also tried calling sh:
    COMMAND: bin/sh
    PARAMETER_LIST:
    RESULT_CODE:
    SCRIPT: /usr/bin/vmrun -T server -h https://server:port/sdk -u user -p userpassword -gu guest -gp guestpassword runProgramInGuest "[standard] VM/Virtual Machine.vmx" -activeWindow -interactive "c:\path_to_program\program.exe" /switch
    SUCCESS_THRESHOLD: 0
    also with the same result.
    The process runs in each case, and ends with: "Log file is available", but when I look in the log, I don't see errors or any information that might help me adjust the user defined activity.

    This method works:
    COMMAND: bin/bash
    PARAMETER_LIST:
    RESULT_CODE:
    SCRIPT: /usr/bin/vmrun -T server -h https://server:port/sdk -u user -p userpassword -gu guest -gp guestpassword runProgramInGuest "standard VM/Virtual Machine.vmx" -activeWindow -interactive "c:\path_to_program\program.exe" /switch
    SUCCESS_THRESHOLD: 0
    The issue seems to be caused on an upgrade to OWB 11R2. Our installation does not always update the VALUE entry when a user types in a value, meaning that our entry changes were not reflected into the deployed process package.

  • Running Tasklist command with Administrator Priviledges

    Hi,
    I am trying to use tasklist command in my bat file to retrieve the list of users running some process say test.exe.
    I am using following command in my bat file.
    tasklist /v /fo table /nh /fi "IMAGENAME eq test.exe" > C:\temp\output.txt
    When I run this bat file as administrator, it works fine and gives the names of users. But, when I run it as some other user, it will give UNKNOWN values in the username coulmn. I have given Full Rights to tasklist.exe in C:\Windows\System32 but still the
    issue remains. How can I run the bat file with normal user privileges to get the Usernames?
    Please help. 
    P.S:- I don't want to add the bat file in my Scheduled Task and run the the Task as administrator. That works, but I have to do this without going into making the Scheduled Task.
    Bhushan Chanda

    Hi Mandy,
    Thanks for trying it out. Yes, I know I can use the Scheduled Tasks to run the bat file with Admin Privileges, but just thought, if there is a way round, that will make life of many easier.
    Bhushan Chanda
    Hi, 
    We could run TASKLIST /V to see details similar to what Task Manager shows. While Task Manager is limited to provide only local machine's information. So we could use a user of the local administrator group to list other user names.
    For more detailed information, please refer to the article below:
    Few must-know tools for basic system administration 
    http://sogeeky.blogspot.in/2006/06/few-must-know-tools-for-basic-system.html
    Please Note: Since the website is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.
    Regards, 
    Mandy
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Creating/running Terminal command with Automator

    I am using Parallels Desktop on my iMac. Occasionally after I shutdown Parallels Desktop/Windows the ram it used is not released back, for example, depending on what I'm running in Parallels Desktop I can use upto around 16GB or ram. Ocassionally when I shutdown Windows and in doing that Parallels Desktop too, this ram level does not go back down. I find that going into Terminal and entering the purge command puts the ram level down to what it was before I loaded up Parallels Desktop.
    I was wondering if its possible to use Automator to create a shortcut that I could then either place on my Desktop or Dock and when needed I could just double click on it and it would then load Terminal and then the purge command?
    Or is there another way that I could automate the purge command?

    I managed to work it out for myself.
    I done the following:
    In Automator I chose Application/Run Shell Script. In the box that appeared in the right side I entered purge. I then saved it to my desired location and I then dragged it onto the Dock for easy access.

  • Does running this command helps sql server 2008 r2 for best performance

    Sir,
    1)DBCC SQLPERF('sys.dm_os_wait_stats', CLEAR)
    2)DBCC FREESYSTEMCACHE ('ALL')
    3)DBCC FREESESSIONCACHE
    4)DBCC FREEPROCCACHE
    5)DBCC DROPCLEANBUFFERS
    If not the commands then what will be best idea to make server Retrieve data from Tables.
    And , retrieving data from stored procedures to dashboarr.
    Please , do me a need full.
    Thanks in advance....

    Sir,
    1)DBCC SQLPERF('sys.dm_os_wait_stats', CLEAR)
    2)DBCC FREESYSTEMCACHE ('ALL')
    3)DBCC FREESESSIONCACHE
    4)DBCC FREEPROCCACHE
    5)DBCC DROPCLEANBUFFERS
    If not the commands then what will be best idea to make server Retrieve data from Tables.
    And , retrieving data from stored procedures to dashboarr.
    Above commands are no where related to retreiving data from procedure above commands will clears your waits stats information stored and also will clear cache plans which as Latheesh pointed out can cause performance issue.New plan needs to be created for each
    new query hitting the database.
    Your question seems misterious to me.
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • SQL-Command to long to run with SQL*Plus

    Hello to everyone,
    I'm creating a dynamic SQL Script to run with SQL*Plus.
    The Script contains only INSERT Command.
    The point is that the SQL*Plus supports only SQL-Strings (Commands)
    not longer than 2500 Characters.
    I've considered to split the String in Insert- and Update-Command(s),
    but I've would like first to know if there any simpler way to run these
    Commands on SQL*Plus.
    thanx in Advance
    bm

    SQL> create table t(x varchar2(4000));
    Table created.
    SQL> insert into t values (
    '1234567890........0........0........0........0........0........0........0........0......100' ||
    '1234567890........0........0........0........0........0........0........0........0......200' ||
    '1234567890........0........0........0........0........0........0........0........0......300' ||
    '1234567890........0........0........0........0........0........0........0........0......400' ||
    '1234567890........0........0........0........0........0........0........0........0......500' ||
    '1234567890........0........0........0........0........0........0........0........0......600' ||
    '1234567890........0........0........0........0........0........0........0........0......700' ||
    '1234567890........0........0........0........0........0........0........0........0......800' ||
    '1234567890........0........0........0........0........0........0........0........0......900' ||
    '1234567890........0........0........0........0........0........0........0........0.....1000' ||
    '1234567890........0........0........0........0........0........0........0........0.....1100' ||
    '1234567890........0........0........0........0........0........0........0........0.....1200' ||
    '1234567890........0........0........0........0........0........0........0........0.....1300' ||
    '1234567890........0........0........0........0........0........0........0........0.....1400' ||
    '1234567890........0........0........0........0........0........0........0........0.....1500' ||
    '1234567890........0........0........0........0........0........0........0........0.....1600' ||
    '1234567890........0........0........0........0........0........0........0........0.....1700' ||
    '1234567890........0........0........0........0........0........0........0........0.....1800' ||
    '1234567890........0........0........0........0........0........0........0........0.....1900' ||
    '1234567890........0........0........0........0........0........0........0........0.....2000' ||
    '1234567890........0........0........0........0........0........0........0........0.....2100' ||
    '1234567890........0........0........0........0........0........0........0........0.....2200' ||
    '1234567890........0........0........0........0........0........0........0........0.....2300' ||
    '1234567890........0........0........0........0........0........0........0........0.....2400' ||
    '1234567890........0........0........0........0........0........0........0........0.....2500' ||
    '1234567890........0........0........0........0........0........0........0........0.....2600' ||
    '1234567890........0........0........0........0........0........0........0........0.....2700' ||
    '1234567890........0........0........0........0........0........0........0........0.....2800' ||
    '1234567890........0........0........0........0........0........0........0........0.....2900' ||
    '1234567890........0........0........0........0........0........0........0........0.....3000'
    1 row created.try to break your query in multiple lines in order to avoid
    SP2-0027: Input is too long (> 2499 characters) - line ignored

  • Using C# to run PowerShell command to create VirtualDirectory fails

    I can run these commands with no problem directly in PowerShell. But trying to get C# to run them, I receive errors.
    md d:\ftproot\vdir\test20140317A;
    New-WebVirtualDirectory -Site "[site]/[a virt directory]" -Name test20140317A -physicalPath d:\ftproot\vdir\test20140317A;
    When running in c# through two different means, I receive these errors
    Exception:Caught: "A parameter cannot be found that matches parameter name 'physicalPath'." (System.Management.Automation.CmdletInvocationException)
    A System.Management.Automation.CmdletInvocationException was caught: "A parameter cannot be found that matches parameter name 'physicalPath'."
    Though in Visual Studio , there's something called InteliTrace and it's showing a whole slew of exceptions starting with
    Exception:Thrown: "Unable to load DLL 'wldp.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)" (System.DllNotFoundException)
    A System.DllNotFoundException was thrown: "Unable to load DLL 'wldp.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"
    Exception:Thrown: "Requested registry access is not allowed." (System.Security.SecurityException)
    A System.Security.SecurityException was thrown: "Requested registry access is not allowed."
    Exception:Thrown: "Cannot find path 'C:\Users\jpacella\Documents\WindowsPowerShell\Modules' because it does not exist." (System.Management.Automation.ItemNotFoundException)
    A System.Management.Automation.ItemNotFoundException was thrown: "Cannot find path 'C:\Users\jpacella\Documents\WindowsPowerShell\Modules' because it does not exist."
    Exception:Thrown: "Could not load file or assembly 'Microsoft.IIS.PowerShell.Framework' or one of its dependencies. The system cannot find the file specified." (System.IO.FileNotFoundException)
    A System.IO.FileNotFoundException was thrown: "Could not load file or assembly 'Microsoft.IIS.PowerShell.Framework' or one of its dependencies. The system cannot find the file specified."
    Exception:Thrown: "Cannot find path 'C:\Users\jpacella\Documents\WindowsPowerShell\Modules' because it does not exist." (System.Management.Automation.ItemNotFoundException)
    A System.Management.Automation.ItemNotFoundException was thrown: "Cannot find path 'C:\Users\jpacella\Documents\WindowsPowerShell\Modules' because it does not exist."
    Exception:Thrown: "Process should have elevated status to access IIS configuration data." (System.InvalidOperationException)
    A System.InvalidOperationException was thrown: "Process should have elevated status to access IIS configuration data."
    Exception:Thrown: "Object reference not set to an instance of an object." (System.NullReferenceException)
    A System.NullReferenceException was thrown: "Object reference not set to an instance of an object."
    Exception:Thrown: "Cannot find drive. A drive with the name 'IIS' does not exist." (System.Management.Automation.DriveNotFoundException)
    A System.Management.Automation.DriveNotFoundException was thrown: "Cannot find drive. A drive with the name 'IIS' does not exist."
    Exception:Thrown: "" (System.Management.Automation.ParameterBindingException)
    A System.Management.Automation.ParameterBindingException was thrown: ""
    Exception:Thrown: "The pipeline has been stopped." (System.Management.Automation.PipelineStoppedException)
    A System.Management.Automation.PipelineStoppedException was thrown: "The pipeline has been stopped."
    Exception:Thrown: "A parameter cannot be found that matches parameter name 'physicalPath'." (System.Management.Automation.CmdletInvocationException)
    A System.Management.Automation.CmdletInvocationException was thrown: "A parameter cannot be found that matches parameter name 'physicalPath'."
    These are the two different ways I invoked the script
    PowerShell ps = PowerShell.Create();
    ps.AddCommand("New-Item")
    .AddParameter("Path", newPathName)
    .AddParameter("ItemType", "directory");
    ps.AddStatement().AddCommand("New-WebVirtualDirectory")
    .AddParameter("Site", Properties.Settings.Default.VirtualDirectoryPath)
    .AddParameter("Name", userName)
    .AddParameter("physicalPath", newPathName);
    ps.Invoke();
    and (scriptContents is a string holding the
    Runspace runspace = RunspaceFactory.CreateRunspace();
    runspace.Open();
    Pipeline pipeline = runspace.CreatePipeline();
    pipeline.Commands.AddScript(scriptContents);
    pipeline.Commands.Add("Out-String");
    Collection<PSObject> results = pipeline.Invoke();
    runspace.Close();

    I tried yet another way to make a Virtual Directory:
    public void CreateVirtualDirectory2(string userName, string password)
    string newPhysicalPathName = Path.Combine(Properties.Settings.Default.PhysicalPathForVirtualDirectory, userName);
    StringBuilder sb = new StringBuilder();
    if (Directory.Exists(newPhysicalPathName) == false)
    sb.AppendLine(@"md " + newPhysicalPathName);
    sb.AppendLine("cd iis:");
    sb.AppendLine("cd Sites");
    sb.AppendLine("cd ftp");
    sb.AppendLine(@"New-Item 'IIS:\Sites\ftp\bridgenet\" + userName + @"' -Type VirtualDirectory -physicalPath " + newPhysicalPathName);
    string script = VirtualDirectoryScript(sb.ToString());
    RunspaceInvoke invoker = new RunspaceInvoke();
    try
    invoker.Invoke(script);
    catch (Exception e)
    Console.ForegroundColor= ConsoleColor.Black;
    Console.BackgroundColor = ConsoleColor.Red;
    Console.WriteLine("ERROR: " + e.Message);
    Console.ResetColor();
    And the same exception occurs
    "A parameter cannot be found that matches parameter name 'physicalPath'."
    When I run the script outside of C#, there's no error.
    So no one's responded yet , which is pretty disappointing.

  • Run OS command from Oracle

    Hi All!!
    Which package can help me to run OS command from SQL script?
    Thanks.

    If you are using SQL*Plus to execute the script, you can use the SQL*Plus command HOST. If you are trying to execute an operating system command from a PL/SQL block (i.e. a stored procedure), you would need to use an external procedure or a Java stored procedure that uses Java's shell functionality.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • [SOLVED] Running sudo command to be executed on dmenu

    I'm using "sudo grub-reboot 2". What is the best way to run this command with dmenu, considering that sudo is necessary, without sacrificing security?
    Last edited by Quatro (2014-08-19 00:22:24)

    My dmenu power menu script looks like this.
    power_menu.sh
    #!/bin/bash
    # dmenu2 power menu
    OPT=$(echo -e "suspend\npoweroff\nreboot" | dmenu -f -h 28 -fn "Ubuntu Mono-12" -x 460 -y 370 -w 360 -nb black -nf white -sb white -sf black )
    case $OPT in
    suspend) sudo systemctl suspend ;;
    poweroff) sudo systemctl poweroff ;;
    reboot) sudo systemctl reboot ;;
    esac
    And the following file allows me to run those commands without being prompted for a password.
    /etc/sudoers.d/include
    slithery ALL=(ALL) NOPASSWD:/usr/bin/systemctl suspend
    slithery ALL=(ALL) NOPASSWD:/usr/bin/systemctl poweroff
    slithery ALL=(ALL) NOPASSWD:/usr/bin/systemctl reboot
    Just use these as an example and you should get what you're after.
    Last edited by slithery (2014-08-18 11:52:31)

  • Add does not run with sql server 2008

    Hi all,
    My add on in the development environment does not run with SQL SERVER 2008. It ran well with SQL Server 2005 and sap b1 2207 B.
    On executing the project file system throws an error "YOU ARE NOT CONNECTED TO THE COMPANY"
    we are trying this scenario on a test machine where SAP B1 2007B with temporary license for one month and SQL server 2008
    is installed.
    Help needed.
    Thanking you
    Pradnya

    Hi Use this
    Dim i as integer
    i=oCompany.Connect()
    if i<> 0 Then
    msgbox(ocompany.GetLastErrorDescription ())
    end if
    the you will get the error description also use try catch wherever necessary
    Alternatively you can use
    Dim SboGuiApi As SAPbouiCOM.SboGuiApi
    Dim sConnectionString As String
    Set SboGuiApi = New SAPbouiCOM.SboGuiApi
    sConnectionString = Command
    SboGuiApi.Connect sConnectionString
    Set SBO_Application = SboGuiApi.GetApplication()
    Set ocompany = New SAPbobsCOM.Company 'initialate DI company object
      ocompany = SBO_Application.Company.GetDICompany
    HTH,
    Atul

Maybe you are looking for