VbScript - Process vs Shell
Hi
Can anyone help me wich is the best way to execute a VbScript in Vsual Basic
the script can be for example the next below:
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile("c:\Temp\testfile.txt", True)
MyFile.WriteLine("This is a test.")
This script basically creates a file testfile.txt"in the dir c:\Temp
What i want to know is which is the best way to run this script is using Process or Shell and what are the advantages or disadvantages of using it
Also the type of scripts that i need to run doesn't need any kind of window or error control
Best regards,
Tiago Oliveira
Hi
Can anyone help me wich is the best way to execute a VbScript in Vsual Basic
the script can be for example the next below:
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile("c:\Temp\testfile.txt", True)
MyFile.WriteLine("This is a test.")
This script basically creates a file testfile.txt"in the dir c:\Temp
What i want to know is which is the best way to run this script is using Process or Shell and what are the advantages or disadvantages of using it
Also the type of scripts that i need to run doesn't need any kind of window or error control
Best regards,
Tiago Oliveira
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile("c:\Temp\testfile.txt", True)
MyFile.WriteLine("This is a test.")
For my understaning it is VB6 not VB.NET, you could read this
thread to get where to post this issue.
remember make the reply as answer and vote the reply as helpful if it helps.
Similar Messages
-
Random SP2 error when starting oracle process through SHELL script
Hi All,
I am trying to process data in n-Number of tables through a package. The package is called through a shell script to create start data processing. All calls to the package are in a sql script which is basically exec calls-
exec package.process ('T1','some param');
exec package.process ('T1','some param');
exec package.process ('T..n','some param');
I have a shell script which I use to execute commands from the sql script. There is a reason behind using shell script. For some strange reason, I keep on getting -
ERROR: logon denied - check for valid user with valid privileges
SP2-0640: Not connected
SP2-0641: "EXECUTE" requires connection to server
SP2-0640: Not connected
for some EXEC calls. Problem is, errors are generated at random. So in one run, I get error for T10,T11 and then in next run I might get for some other tables.
However, when I am running the sql script from the sql prompt, all calls to the package are executed without any problem.
This makes me think, it is something to do with the way database connection being initiated through UNIX.
Has anyone faced similar issue? Your help/gudence is much appreciated.
DB: Oracle 10.2.0.5
OS: SUN Solaris 10
Thanks in advance.Login credentials are provided inside the shell script.
I did put a sleep(10) after EOF but no help. As mentioned if I run script file from sql promt, it runs without any hiccup. So it is the connection through the UNIX that is causing issue.
As pointed out by Sybrand, I agree that it does not make a sense to connect and commit after every sql statement. So decided to change the shell script and so far, the result from my initial tests on a sample data is quite encouraging. Hopefully I will have a solution.
But it will be nice to know why SHELL is doing what it is doing!!
Legacy prog are sometime big time eye-openers..;) -
BPEL processes and shell scripts
Hi,
I wish to invoke BPEL processes from a shell script so that it could be regulated from a typical Control-M environment. Can anybody let me know if its possible...?
Regards,
RoySome kind-of Java interface would just be fantastic. Is there anything like that...?
Well, I intend to execute some batch processes which would be scheduled and administered by Control-M; If i opt to use ws-clients within the same then auditing and monitering the status of my executing process would be an obvious overhead that i might need to hard wire in my implementation. Therefore, should it be possible to execute a BPEL process from a Java like interface, which i'd then wrap in a shell script; then Control-M on itself would be capable of monitoring the process status and all other performance parameters around the same.
Suresh - Thanks for your suggestion, will definately post the message on those groups as well. -
Automatic import process through shell script
Hi all,
oracle 10.2.0
RHEL 4
I have many export dump files in one directory exported from different schemas and different databases.
I have to import them in different schemas in a single database.Ofcourse, I can manually import each file but to avod tedious work,i want to automate the task.I want linux do it for me.I wrote the below script but it works only for the first time.
USR=system
PWD=******
for $i in `ls *.dmp`;do
imp $USR/$PWD file=$i fromuser=test touser=`basename` $i
done
What else should i include in the script os that automatically oracle navigates through every dump file and import the database in the respective schema?
ThanksBefore trying a solution I have to understand something more...
Are your dump file names <schema name>.dmp, e.g. user1.dmp, user2.dmp and so on, and you want to import into those schemas ? If so, is "fromuser=test" correct ? If not so, please clarify.
And why "basename" ? -
Pass output parameter from mapping to external process in a Process Flow
In Process flow, how do we pass an Output parameter from a mapping (generated by a post mapping operator) into an external process (shell script)?
I have a mapping that generates an output parameter and I would like to pass this parameter to an external process (a shell script) with a process flow. Is this possible?Hi Norman,
Unfortunately in the current release, you cannot do this. What you can do, is store the value into a table and read it in the external process, or write it into a file and read it from there. The next release will support passing output parameters from one activity to the next.
Thanks,
Mark. -
Executing Unix shell from Java Program
Hi,
I have written a java application using Maverick J2sshtools API which connects to a Unix box using SSH.The program authenticates with the remote box successfully,but It dosen't return the environment info or execute the test script.Have attached the complete code.
package shellInteraction;
import com.maverick.ssh.*;
import com.maverick.ssh2.Ssh2Client;
import com.maverick.ssh2.Ssh2Context;
import com.maverick.ssh2.Ssh2PasswordAuthentication;
import com.sshtools.net.*;
import java.io.*;
import java.util.Iterator;
import java.util.Vector;
public class JavaShell{
public static void main(String[] args) {
SshConnector con = null;
SshClient ssh = null;
ShellProcess process = null;
Shell shell = null;
try{
// Create a session to remote host
con = SshConnector.getInstance();
ssh = connectionSetup(con);
System.out.println(ssh);
// Start a session and do basic IO
if (ssh.isAuthenticated()) {
shell = new Shell(ssh);
System.out.println("Authenticated");
if(shell.getEnvironment().hasEnvironmentVariable("hostname"))
System.out.println("We are connected to " + shell.getEnvironment().getEnvironmentVariable("hostname"));
//System.out.println("Remote operating system is " + shell.getEnvironment().getOperatingSystem());
// boolean isWindows = shell.getEnvironment().getOSType()==ShellEnvironment.OS_WINDOWS;
//if(shell.getEnvironment().hasEnvironmentVariable("USERPROFILE")) {
//System.out.println("User home is " + shell.getEnvironment().getEnvironmentVariable("USERPROFILE"));
//} else if(shell.getEnvironment().hasEnvironmentVariable("HOME")) {
//System.out.println("User home is " + shell.getEnvironment().getEnvironmentVariable("HOME"));
// Commands only executed for Unix OS
//if(!isWindows) {
// Execute a script
traverseDirectory(shell);
shell.exit();
ssh.disconnect();
System.out.println("Shell has exited");
} catch(Throwable t) {
t.printStackTrace();
private static void traverseDirectory(Shell shell) throws Exception{
System.out.println("\n\nTraverse Directory");
// Execute a simple script than prints a directory tree
ShellProcess process = shell.execute("bash test.sh ");
try{
process.expect("Total directories", 1000, true);
System.out.print(process.toString());
} catch (ShellTimeoutException ex1) {
System.out.println("TRAVERSE Expect operation timed out. Sending interrupt to kill the process");
process.interrupt();
}finally {
process.close();
static private Ssh2Client connectionSetup(SshConnector con)throws SshException{
Ssh2Client ssh = null;
final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
System.out.print("Hostname: ");
String hostname = reader.readLine();
int idx = hostname.indexOf(':');
int port = 22;
if(idx > -1) {
port = Integer.parseInt(hostname.substring(idx+1));
hostname = hostname.substring(0, idx);
System.out.print("Username [Enter for " + System.getProperty("user.name") + "]: ");
String username = reader.readLine();
if(username==null || username.trim().equals(""))
username = System.getProperty("user.name");
System.out.println("Connecting to " + hostname);
* Create an SshConnector instance
con = SshConnector.getInstance();
// Lets do some host key verification
HostKeyVerification hkv = new PasswordHostKey();
con.setSupportedVersions(SshConnector.SSH2);
* Set our preferred public key type
con.getContext(SshConnector.SSH2).setHostKeyVerification(hkv);
((Ssh2Context)con.getContext(SshConnector.SSH2)).setPreferredPublicKey(Ssh2Context.PUBLIC_KEY_SSHDSS);
* Connect to the host
ssh = (Ssh2Client)con.connect(new SocketTransport(hostname, port), username, true);
* Authenticate the user using password authentication
Ssh2PasswordAuthentication passwordAuthentication = new Ssh2PasswordAuthentication();
System.out.print("Password: ");
passwordAuthentication.setPassword(reader.readLine());
if(ssh.authenticate(passwordAuthentication)!=SshAuthentication.COMPLETE) {
System.out.println("Authentication failed!");
System.exit(0);
}catch(Exception ex1) {
throw new SshException(ex1.getMessage(), ex1.getCause());
return ssh;
When I execute the program
Hostname:****
Username [Enter for thaya]: **
Connecting to CATL
The connected host's key (ssh-dss) is
b6:85:91:6b:8b:ea:cb:40:b5:6f:01:2e:66:78:7f:62
Password: *****
SSH2 CATLMSXP62:22 [kex=diffie-hellman-group1-sha1 hostkey=ssh-dss client->server=aes128-cbc,hmac-sha1,none server->client=aes128-cbc,hmac-sha1,none]
Authenticated
Traverse Directory
com.maverick.ssh.ShellTimeoutException: The shell did not return to the prompt in the given timeout period 10000ms
at com.maverick.ssh.Shell.A(Unknown Source)
at com.maverick.ssh.Shell.execute(Unknown Source)
at shellInteraction.ShellInteraction.traverseDirectory(ShellInteraction.java:108)
at shellInteraction.ShellInteraction.main(ShellInteraction.java:68)
This is the error message what i get.use code tags if you want a response,
ive done the same thing once using
ssh2.ethz.ch ie:
import ch.ethz.ssh2.Connection;
import ch.ethz.ssh2.ServerHostKeyVerifier;
import ch.ethz.ssh2.Session;
the code looked something like this:
try
conn.connect(new ServerHostKeyVerifier() {
public boolean verifyServerHostKey(String hostname, int port, String serverHostKeyAlgorithm, byte[] serverHostKey) throws Exception {
return true;
conn.authenticateWithPassword(username, password);
try {
sess = conn.openSession();
} catch (java.lang.IllegalStateException e) {
return;
// JOptionPane.showMessageDialog(null, "Could not autheticate.\nCheck username and password.\nTerminating.", "Authentication Failed", JOptionPane.ERROR_MESSAGE);
// System.exit(-1);
sess.requestPTY("dumb", 50, 50, 0, 0, null);
sess.startShell();
}and after that sess has getStdIn() and getStdOut() that get the streams from which you read and write. -
Please help to call oracle procedure with out paramter from shell script
Hi
I want to call a process with out parameter from shell script. I am calling process in shell script in below way
function Process_loads {
( echo 'set serveroutput on size 1000000 arraysize 1'
echo "set pagesize 0 term on verify off feedback off echo off"
echo "BEGIN"
echo " dbms_output.put_line('Before Calling The package'); "
echo " x ( '$1', '$2', '$2', '$4', '$5', '$error_code'); "
echo " dbms_output.put_line('After Calling The package'); "
echo "EXCEPTION "
echo " WHEN OTHERS THEN "
echo " dbms_output.put_line('BIN_LOAD_ERROR' || SQLERRM); "
echo " ROLLBACK;"
echo "END;"
echo "/" ) | sqlplus -s $USER/$PASSWORD@$SID
Here $error_code is out paramter. All varaibles passed in process are declared with export command.
When executing .sh it gives below error
"sh ERROR at line 3: ORA-06550: line 3, column 99: PLS-00363: expression '' cannot be used as an assignment target ORA-06550: line 3, column 3: PL/SQL: Statement ignored".
Please help to get rid from this error or please suggest how to call a oracle procedure with out paramter from unix shell script.
Thanks in advanceYou can try this:
From sql*plus
SQL> ed
1 create or replace procedure my_proc(p_id in int, p_result out int)
2 as
3 begin
4 select 10 * p_id
5 into p_result
6 from dual;
7* end my_proc;
SQL> /
Procedure created.
SQL> set serveroutput on
SQL> declare
2 v_r int;
3 begin
4 my_proc(10,v_r);
5 dbms_output.put_line(v_r);
6 end;
7 /
100
PL/SQL procedure successfully completed.
from bash:
testproc.sh:
#!/bin/bash
(echo 'set serveroutput on';
echo 'declare';
echo 'v_r int;';
echo 'begin';
echo 'my_proc(10,v_r);';
echo 'dbms_output.put_line(v_r);'
echo 'end;';
echo '/';) | sqlplus -s u1/u1
Console:
oracle@mob-ubuntu:~$ chmod u+x testproc.sh
oracle@mob-ubuntu:~$ ./testproc.sh
100
PL/SQL procedure successfully completed.With kind regards
Krystian Zieja -
F60srvm process dies under Solaris
We are running OAS 4.0.7 under Solaris 2.6 with Oracle 8.0.5.
Our version of Developer 6 is 6.0.5.0.3.
We get a process started with "f60ctl start"
The server process dies when we invoke the form in a browser.
Anybody have any suggestions?If you start a background process, the shell remembers its pid in $!.
That can be used to store the pid in a pid-file, which may be useful when stopping the thing or preventing multiple starts.
Or you can also use a wrapper script around the java program which remembers the java process's PID and traps the exit and sigstop signals, and in the trap stops the java process. Thus you have to find your own script process, not the java process
BTW: is there any special way to stop your java process or you want just to send it a SIGTERM signal? -
Removing carriage reutrn using shell script
Hi Team,
My requirement comes like this,
I am having the following data in the file1,
UNB+UNOC:3+IRM CONSULTING+ATBAA+110425:0700+TEST 230154++PAYMUL'
UNH+TEST 230154+PAYMUL:D:96A:UN'
BGM+452+TEST 230154'
I would like to read the data from file1 and write the data into file2 as below
UNB+UNOC:3+IRM CONSULTING+ATBAA+110425:0700+TEST 230154++PAYMUL'UNH+TEST 230154+PAYMUL:D:96A:UN'BGM+452+TEST 230154'
This needs to be achieved using a shell script.
I dont know about shell script,Please provide the step by step process of shell script for achieveing the above requirement.
Thanks.Hi;
Please see:
http://en.kioskea.net/faq/1757-how-to-read-a-file-line-by-line
http://www.linuxquestions.org/questions/programming-9/bash-shell-script-read-file-line-by-line-136784/
If its not help i suggest move your issue to Forum Home » Linux » Generic Linux from part
Regard
Helios -
How can I run a script when an application quit??
Greetings all,
I'm trying to write a script, which can be triggered automatically (to do some stuff) at the time when a given application quit. I was playing around with this test script, taking "TextEdit" as an example - it just prints a message when TextEdit exits.
==========================================
+*set targetapp to "TextEdit"*+
+*tell application "System Events" to set rr to name of the processes*+
+*--if targetapp is not in rr then*+
+*-- tell application targetapp to activate*+
+*-- tell application "System Events" to set rr to name of the processes*+
+*--end if*+
+*set rr1 to rr*+
+*repeat until rr1 ≠ rr and targetapp is not in rr1*+
+*tell application "System Events" to set rr1 to name of the processes*+
+*do shell script "sleep 1"*+
+*end repeat*+
beep
+*display dialog (targetapp & " is not active anymore !") as string buttons {"OK"} default button 1 with icon 0*+
============================================
Unfortunately, it seems to work if I launch TextEdit using the script itself; it doesn't work with first +*"if - end if"*+ block commented out. Does anyone know how can I achieve this? Any help or suggestion greatly appreciated. Cheers!!Hi santanu,
I'm sure you can use a variation of this application of mine to do what you want. It monitors all running processes and then reports when one closes.
--initialize previous_processes
global previous_processes
tell application "Finder"
set previous_processes to get the name of every process --use "whose visible is true" to remove the background ones
end tell
--monitoring script
on idle
tell application "Finder"
set current_processes to get the name of every process
end tell
set numberofprocesses to count of items in previous_processes
set counter to 1
repeat while counter is less than (numberofprocesses + 1)
if current_processes does not contain item counter of previous_processes then
display alert item counter of previous_processes & " quit!"
end if
set counter to counter + 1
end repeat
set previous_processes to current_processes
return 1 --runs every second...can be changed
end idle -
Need help in OS command problem in File adapter.
Hi All,
In channel configuration, I configured "run operating system command before message processing" with shell file. But,I foundnd that every time I change the shell file, it won't take effect until I restart PI system. So, could you please tell me whether there is way to avoid this or give a solution of this?
It is relaly very very yrgent for me.
Waiting for positive replies.
Regards,
Prakash.Dear Prakash,
Even you have changed the shell file, but the CPA cache used in runtime
remains unupdated. Restarting PI system or performing CPA cache refresh
manually can trigger CPA cache refresh, but you can try a simple way:
You can do dummy change in communication channel configuration in
Integration Directory(for example, add a space mark in description field
in channel configuration and activate the change list), then a cache
refresh is triggered.
Please try.
Regards,
Tulika Bhatt -
How to get rid of ttys000 in terminal
I got ttys000 in my terminal in front of my name and sometimes terminal say restored
From Terminal's help:
Change the title shown in the Terminal window
You can change the text in the title bar of a Terminal window to display a variety of information about the window’s configuration.
Choose Terminal > Preferences, and then click Settings.
Click Window.
Select a setting to modify from the Settings list, located on the left side of the Settings pane.
In the Title section, enter the name you want to appear in the title bar of the Terminal window.
Select the items you want to appear in the title bar of the Terminal window:
Active process name:
The currently running process.
Shell command name:
The shell being used in the window.
Settings name:
The settings being used to configure the window.
TTY name:
The current name of the terminal. The name is equivalent to the result of the tty command in UNIX.
Dimensions:
The number of columns and rows in the window.
RELATED TOPICS
Change the appearance of Terminal windows -
Hi All,
Can any one help me out what exactly this code means ???
if not "%1"=="wkdxz" mshta vbscript:createobject("wscript.shell").run("""%~f0"" wkdxz",vbhide)(window.close)&&exit
@echo off
set /a ID = "2013"
:kill_OPC
ping -n 600 -w 10 172.16.4.27
tasklist | find "AfwDsOpcSurrogate.exe" >>temp.txt
for /f "tokens=2" %%i in (temp.txt) do @set /a ID = %%i
taskkill /pid %ID% /f
del temp.txt
goto kill_OPC
Thanks in advance
Regards
SanthoshHi Santhosh,
Based on your description, this issue is more related to scripting. I suggest that you would post your question
in the
Official Scripting Guys Forum. I believe we will get a better assistance there.
Best regards,
Justin Gu -
Hi everyone, I have a multi-threaded application that basically starts external programs ( bash scripts ) using Runtime.getRuntime().exec(unixCmd); The thread waits for the process to finish and when it does, returns the return code from the process. During peak period, it's not rare that the program reaches at least 5 concurrent threads, therefore 5 process are running at the same time.
We used to run this program on Solaris 10 u2 using Java 1.5.0_6 and we never had any problem whatsoever. Recently, we moved the application to a new server running on Solaris 10 u4 using Java 1.5.0.15 and the problems started... We observed that about 1% of all the process launched hang. Even the destroy() method of the process has no effect. The only way to stop the process is with the cmd kill -9. We also observed that the script called by the application is not executed at all, not even the first line.
Here is my code:
Runtime shell = Runtime.getRuntime();
Process proc = shell.exec(cmd_unix_final);
if (Server.getProperty(PROP_LOG_ENABLED).toLowerCase().equals("true"))
outputGobbler = new StreamGobbler(proc.getInputStream(), Server.getProperty(PROP_LOG_OUTPUT_FILE), Server.getPhase());
errorGobbler = new StreamGobbler(proc.getErrorStream(), Server.getProperty(PROP_LOG_ERROR_FILE), Server.getPhase());
outputGobbler.start();
errorGobbler.start();
do
try
returnValue = proc.exitValue();
processFinished = true;
catch (IllegalThreadStateException e)
try { Thread.sleep(sleepInterval);}catch(InterruptedException ex){ex.printStackTrace();}
while (System.currentTimeMillis() - launchTime < threadTimeout * 1000 * 60 && !processFinished);
if (!processFinished)
proc.destroy();
returnValue = ServerReturnCodes.SERVER_RETURN_CODE_TIMEOUT_ERROR;
return returnValue;
...If you have any idea what is causing the problem, please let me know, thanks!Thank you both for your replys. We are going to try an other version of Java soon... As for the process, the bash script does not even gets executed, the process hangs before that, at the creation phase.
-
Set $PATH for current session in Terminal
Hello,
I want to modify the environment variable $PATH for the current terminal session. To modify it in $HOME/.profile (etc) is no option.
So I created a shell script called envsetup.sh which contains
ATLAS_HOME=/Applications/Development/atl-plugin-sdk
PATH=$ATLAS_HOME/bin:$PATH
export ATLAS_HOME PATH
When I execute the script, $PATH will only modified while running the script but does not alter it for the current session. But then I copy and paste it into the terminal, $PATH gets modified for the current session. What's wrong with it? On my Linux box, it works ...Linux box, it works ...
This CANNOT work on your Linux box.
When you run a shell script (Mac OS X, Linux, HP-UX, Solaris, Tru64 UNIX, AIX, etc...), the shell script is runs in a child process. Any environment variables set or changed in that child process get destroyed when that child process ends, which happens as soon as the script ends. The parent process (your shell) will never see those child process environment variables. This has been true since the earliest versions of UNIX that I am aware of, and that goes back to at least '79.
Alternative approaches. You could create a shell function in your .profile
envsetup()
export ATLAS_HOME="/Applications/Development/atl-plugin-sdk"
export PATH="$ATLAS_HOME/bin:$PATH"
The next time you login, your .profile will run and you will have a new command "envsetup". When you invoke the command envsetup it will run within the context of your current shell, so those environment variables will be set and visible.
You could also create an alias that sources your envsetup.sh
alias envsetup 'source /path/to/envsetup.sh'
This would give you an easy to call command that would source into the current shell the export commands, as well as provide you with a script that can be sourced into other scripts that happen to need those specific exports.
Message was edited by: BobHarris
Maybe you are looking for
-
Iphoto won't send photos by email?
Although photos look as though they have been sent by email they are not in fact transmitted. can anyone help please?
-
I just had the absolute worst experience ever with some idiot at Adobe's chat support. He took control of my computer and started renaming files to old, without keeping the original name (original.old) like he should have. What he was trying to do d
-
Does anyone know how to reconnect Boris Title 3D in Final Cut 6? I haven't found any of the current topics applicable. Thanks!
-
Page cannot be displayed error in Jdev 10.1.2
I am new to jdeveloper and have just installed oracle8i and jdev 10.1.2. on my home pc.Also i have a broadband internet connection. When i am connected to the network my project runs but when i switch off the internet then i get an error saying page
-
Authorization issue on hire action through HCM Process and Forms
Hi All, We are executing hiring action through HCM form process. The process is using the HR_PL_ADMINISTRATOR role on ECC which is super admin access to execute the action and HR administrator role on the portal. If we restrict the role with persona