How to give filename at Command Line
Hi,
what do I do to make sure that when my user gives a command line argument like "-Dn" and then a filename , the system writes to that file.
I have everything working properly and can achieve the same thing using a properties file, but do not know what to do in this case. Here is a snippet from my code:
if(args.equalsIgnoreCase("-Dn")) {
obj.setLogFileName(); //what to do here???
The setLogFileName method resides in a class which writes to the disk and is working properly
Thankx in advance...
If you are usgin the command line syntax you are describing, like "java MyClass [arguments]" you can just go on traversing the argument list:
String fileName = args[0];
However, you can also do this as follows:
java -Dlogfile=<the path> MyClass [arguments]
In that case the <the path> string is available as a system property named "logfile", and can be retrieved as this:
String fileName = System.getProperty( "logfile" );
Similar Messages
-
Filenames as Command Line Arguments: How?
i need to create a program that involves taking in a file name as command line argument, reads the file and then displays its contents on the screen. it needs to work with any file with a .txt extension.
The only thing i dont fully understand is how to read the file name as a command line argument e.g.
"java FileReaderApp myfile.txt
----contents of file--------
Thanks in advance
Carl
P.S. I have lready read the various helps, utils etc for java and still dont really understandOkay, first, it will help if you don't think of "filenames as command line args." The two concepts are totally independent.
Command line args are Strings. What you do with those Strings is up to you. Processing the command line args is the same, regardless of whether they represent file names or the turnons of the last 50 playmates.
The args array below contains the command line args.
public static void main(String[] args) {
// do stuff
} Files are generally referred to using the java.io.File. It takes a String for the file name. It doesn't matter where the String comes from.
Look at FileReader and BufferedReader to actually read the contents of the file.
http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileReader.html
http://java.sun.com/j2se/1.4.2/docs/api/java/io/BufferedReader.html
For the basic command line arg stuff, one of the following should have some info and examples
http://java.sun.com/docs/books/tutorial/
http://java.sun.com/learning/new2java/index.html
http://javaalmanac.com
http://www.jguru.com
http://www.javaranch.com
Bruce Eckel's Thinking in Java
Joshua Bloch's Effective Java
Bert Bates and Kathy Sierra's Head First Java -
How to give the no of lines per a page in alv report
hi
could u plz inform me
how to give the no of lines per page in alv report
in ordinary report we can give line-count na
how can we give in alvs.
thanx
kals.Hi Kalyan,
There is another Forum(Abap Development) where u can post abap related stuffs and u can also get quick answers there..
Cheers...
Santosh -
How to set SAXParser at command-line interface to create a large XML file
Hi,
I am trying to create a large XML file (more than 50 MB) by selecting from Oracle database but failed because of "out of memory" error. According to "Oracle XML Developer Guide", we should use SAXParser to parsing a large XML file. But there is no example to show how to set SAXParser at command-line
Following is what I use to get xml files. It works only when the file is small.
java OracleXML getXML -DateFormat -withDTD -rowsetTag PO_HDR -conn
"jdbc:oracle:oci8:@server_name" -user "ID/password" "select * from table_name"
When I set SAXParser at the way below,
java oracle.xml.parser.v2.SAXParser OracleXML getXML -DateFormat -withDTD -rowsetTag PO_HDR -conn
"jdbc:oracle:oci8:@server_name" -user "ID/password" "select * from table_name"
it failed with the error message: "In class oracle.xml.parser.v2.SAXParser: void main(String argv[]) is not defined"
Does anyone know how to solve the problem? I'll be appreciated very much for your help.
Yihere are my ideas.
register the xml schema.
using xmldom, generate the desired xml output and return as xmltype.
then you can use something like this to check.
declare
xmldoc xmltype ;
begin
-- populate xmldoc from you xmldom function
-- validate against XML schema
xmldoc.isSchemaValid(schema_url, root_element);
if xmldoc.isSchemaValid = 1 then
--valid schema
else
--invalid
end if;
end -
How do you put a command line in adobe illustrator?
how do you put a command line in adobe illustrator?
Your question makes no sense. What exactly are you trying to do?
-
How can I use srvctl command line for change "Failover type" and "F method"
Hi all,
I am using Oracle One Node (11.2.0.3), and I have a service:
/u01/11.2.0/grid/bin/srvctl config service -d orcl
Service name: orcldb
Service is enabled
Server pool: orcl
Cardinality: 1
Disconnect: false
Service role: PRIMARY
Management policy: AUTOMATIC
DTP transaction: false
AQ HA notifications: false
Failover type: NONE
Failover method: NONE
TAF failover retries: 0
TAF failover delay: 0
Connection Load Balancing Goal: LONG
Runtime Load Balancing Goal: NONE
TAF policy specification: BASIC
Edition:
Preferred instances: orcl_1
Available instances:
I would like to change "Failover type" and "Failover method" to:
Failover type: SELECT
Failover method: BASIC
How can I do that? Is there any graphical tool for it? Or, How can I use srvctl command line for change it?
Thanks in advance.
Leonardo.user10674190 wrote:
Hi all,
I am using Oracle One Node (11.2.0.3), and I have a service:
/u01/11.2.0/grid/bin/srvctl config service -d orcl
Service name: orcldb
Service is enabled
Server pool: orcl
Cardinality: 1
Disconnect: false
Service role: PRIMARY
Management policy: AUTOMATIC
DTP transaction: false
AQ HA notifications: false
Failover type: NONE
Failover method: NONE
TAF failover retries: 0
TAF failover delay: 0
Connection Load Balancing Goal: LONG
Runtime Load Balancing Goal: NONE
TAF policy specification: BASIC
Edition:
Preferred instances: orcl_1
Available instances:
I would like to change "Failover type" and "Failover method" to:
Failover type: SELECT
Failover method: BASIC
How can I do that? Is there any graphical tool for it? Or, How can I use srvctl command line for change it?
Thanks in advance.
Leonardo.srvctl modify service -d database_name -s orcldb -q TRUE -m BASIC -P BASIC -e SELECT -z 180 -w 5 -j LONG
Also see
11gR2(11.2) RAC TAF Configuration for Admin and Policy Managed Databases [ID 1312749.1] -
How can I deploy by command line on AS 10.1.3?
I have used oracle AS 10.1.3.
I have created ear file from command line.
But I don't know how i can deploy by command line?
However i can deploy from Web manage.
So, Please tell me How i can deploy by command line when i want?
ThxHello,
In OracleAS 10g R3 (10.1.3.x) you can deploy by command line using the admin_client.jar utility, that is exposed also as Apache Ant tasks. In 10.1.3.x you can use the same tool to deploy in a single stand alone OC4J instance to a multi-nodees cluster managed by OPMN.
Here the documentation about this utility:
- Deployment Guide
- Deploying with the admin_client.jar Utility
-Deploying with the OC4J Ant Tasks
Regards
Tugdual Grall -
How to use the telnet command line in Labview
Hi, someone can help me, I need to use a Telnet session in Labview but without using the http protocol, in this application I can only access the Telnet session using command line, here is an example of how I can access:
From my computer, click on Start, then Run and then type in CMD.
In the command line enter “telnet 192.168.0.1 5454” (without the quote marks) to bring up a blank DOS screen with a blinking cursor.
Type “AT” and press the ENTER key, you should receive an “OK” response.
Type in capital letters “AT+CMAR=1234” (without the quote marks)I had a similar situation and here is what I did...
In MAX (Measurement and Automation eXplorer)
Select Devices and Interfaces
Select VISA TCP/IP Resources
Create a new resource
Select Manual Entry of Raw Socket
Enter the IP address and port (23 is the standard telnet port)
Give it a name. (VISA Ailas)
Now this "Device" will show up in the VISA drop down just like any other VISA device.
Use the VISA read and write just like you were communicating through a com port.
Since Telnet does not have a stop bit like serial, make sure you enable the termination character.
On your VISA reads set the number of characters to a big number, then VISA will read until it gets the termination character.
See my attached snippet of my Telnet read vi
Message Edited by RTSLVU on 06-16-2010 01:49 PM
Message Edited by RTSLVU on 06-16-2010 01:50 PM
Attachments:
telnet.png 40 KB
max1.png 33 KB
max2.png 31 KB -
How do I create a "command-line-interface" for a game?
Hey people,
For a game I need to make a DOS-like command-line-interface where the user has at least 3 options to answer with, does anyone know how to go about this?
Hope someone here can help me out!
Kind regards,
AngelaI'm not sure what part of this you are having difficulty with. Imagine for a moment that instead of asking for your end user to type something into a text-entry field and to monitor what they type (perhaps when the ENTER key is pressed), that instead you provide 3 buttons on your stage. Responding to a button press in this scenario is much the same as responding to typed user input - your movie does something based on user interaction. Going back to the user entered text scenario, a text or field sprite can detect the ENTER key being pressed and examine the string the user has entered, something like:
on keyDown me
if _key.keyCode = 36 then
stopEvent
sText = sprite(me.spriteNum).member.text
case sText of
"hack": -- do whatever you need to here
"research":
"wait":
otherwise:
end case
else
pass
end if
end -
[RESOLVED] How I pass in my command-line variables disgusts me
Hello,
What I'm trying to do is to make an easily configurable script that the user can run with just a few basic command line variables (some of our users are not programmers.) Now, here's my problem, when it comes to extracting the variables from the command line, it's kind of messy. Lets say I have the following command:
$ ./hl_script.sh --config-file=config_abc.txt --rate=5000 --data-dump=/opt/dump_area -v
"-v" means verbose
Now, given the weird arrangement of the different types of command line arguments, I'd like to extract the salient parts of the information that I care about. However, at this moment, all I have is the "cut" command which can easily get into undefined behavior territory should the user misstype an input. I would love to know how you have done this and what your approach to this problem is.
This is the code that I have so far:
# this is where we run the initial test and check if the user entered the
# help flag in order to see how to properly use this application.
if [ $# -gt 1 ]; then
for argument in $@
do
if [ $argument = "--help" ]; then
echo "Here is how you would use this software and the flags that would"
echo " be useful."
echo " --help"
echo " Brings up this display and shows a listing of the options"
echo " that can be used to better utilize this app."
echo ""
echo " --config-file=N"
echo " Specify the config file that we'd like to use."
echo ""
exit 0
elif [ `cut $argument | cut -d'=' -f 1` = "--config-file" ]; then
# read-in the config file that we specified and then proceed to set a
# bunch of environment variables that we need.
echo "stuff..."
fi
done
fi
Last edited by publicus (2014-05-13 13:13:43)ewaller wrote:
I know your sample code is Bash, but you may want to consider doing it in Python and using this library
Here is a simple Python program I wrote that uses the library:
ewaller$@$odin ~/devel/python 1004 %./sieve.py
Usage: sieve.py [options] arg
sieve.py: error: incorrect number of arguments
ewaller$@$odin ~/devel/python [2]1005 %./sieve.py 10
2 3 5 7
ewaller$@$odin ~/devel/python 1006 %./sieve.py --help
Usage: sieve.py [options] arg
Find prime numbers using a sieve of Eratosthenes
Options:
-h, --help show this help message and exit
-v, --verbose
ewaller$@$odin ~/devel/python 1007 %./sieve.py 10 -v
removing 4
removing 6
removing 8
removing 10
removing 6
removing 9
removing 10
2 3 5 7
ewaller$@$odin ~/devel/python 1008 %cat sieve.py
#! /usr/bin/python
Implement a sieve of Eratosthenes
from optparse import OptionParser
def main():
#Handle all the command line nonsense. We need a number as an argument
usage = "%prog [options] arg"
description = "Find prime numbers using a sieve of Eratosthenes"
parser = OptionParser(usage=usage,description=description)
parser.add_option("-v", "--verbose", action="store_true", dest="verbose")
(options, args) = parser.parse_args()
if len(args) != 1:
parser.error("incorrect number of arguments")
try:
maxval=eval(args[0])
except:
parser.error ("Argument is not a number")
# Here is the sieve
a=[x for x in range(0,maxval+1)]
for count in range(2,int(maxval/2)+1):
if a[count]:
for i in range(count*2,maxval+1,count):
a[i]=0
if options.verbose:
print ("removing %i"%i)
# and report the results
wrap=0
for count in range(2,len(a)):
if a[count]:
print (count,end=" ")
wrap += 1
if (wrap == 5):
print()
wrap = 0
print ()
if __name__ == "__main__":
main()
ewaller$@$odin ~/devel/python 1009 %
The thing is, I already have some shell code written that works, so I don't want to re-write (and re-test) that. -
How to run report on command line with user parameter?
Hi,
How do I run oracle report on command line (batch) with pre-set User Parameter values ? e.g. :P_1 ='SYSDATE' , :P_2 = 'DEPT_NO'
ThanksHello,
If you are using rwrun :
rwrun report=myreport destype=file desname=c:\temp\myreport.pdf desformat=pdf P_1='SYSDATE' P_2='DEPT_NO' userid=scott/tiger@dbalias
If you are using rwclient , just add server=<reports server name> :
rwclient server=myrepsevrername report=+myreport+ destype=file desname=c:\temp\myreport.pdf desformat=pdf P_1='SYSDATE' P_2='DEPT_NO' userid=scott/tiger@dbalias
Regards -
How do I pause C command-line program?
Hello. I'm writing a little command-line game app in C and I'm curious about how I can pause the program to wait for the user to hit return. I want the user to need to hit return (or having to hit any key would work too) to make the program continue, and I would like the key that was hit not to appear on the screen -- just a simple sort of "hit any key to continue" type thing. In C++ I think we used something like system("Pause") or something like that -- don't really remember, but any help here will be greatly appreciated. Thanks!
Something like this will print a prompt, then wait for a keystroke:
printf("Hit any key to continue> ");
getchar();
However in a console application, it's not so easy to prevent the user's keystrokes from being echoed. There are ways to turn the echo off for the keystroke then restore it, but those can depend on the environment. I'd need to know whether you're running your program in an Xcode console window, a Terminal window, or elsewhere. In short, don't go there unless it's quite important to you. The above prompt will show any chars that are keyed-in as text after the arrow, which is what a user would expect.
Hope that helps!
- Ray -
How do I process user command line arguments inside of the Sequence Editor?
Using TestStand 4.0, how would I go about storing "extra" command line arguments processed from the /runentrypoint command in the Sequence Editor specifically?
djdewitt -
TestStand 4.2 does not have this feature; however, we do have an internal issue (#163169) to track this request. You can actually get the commandline passed to the TestStand Sequence Editor using the below psuedo code in a sequence; however, currently the TestStand Sequence Editor displays a prompt when it does not recognize a custom token on the command-line and there is no way to suppress this.
Locals.AppMgrRef = RunState.Engine.GetInternalOption(InternalOption_ApplicationManager);
Locals.CommandsRef = Locals.AppMgrRef.CommandLineArguments;
Locals.CountNum = Locals.CommandRef.Count;
For i=0 to Locals.CountNum - 1
Locals.CommandString = Locals.CommandRef.Item(i);
End
One suggestion is to use a batch file to write the commands to a dedicated text file and then launch the sequence editor. You can then use a sequence in the sequence editor to read from the file.
Lastly, I just tried something and I do not necessarily recommend this, but I noticed that the Sequence Editor does not prompt when using the /goto token, so if I use the below command-line, it seems that no prompt appears, the goto command does nothing, and the psuedo code accesses the command-line tokens:
"C:\PathToApp\SeqEdit.exe" /goto "location tokens that do nothing" /run MainSequence "C:\PathToSequenceFile\GetCommandLineArgs.seq"
Keep in mind that NI does not necessarily support this but it does seem to work for now.
Scott Richardson
National Instruments -
Hi everyone,
I want to set up my email composition with a default [email protected] address in the "Reply-to" field that is different from my ISP. How do I configure mail to set this default?
I have looked through the help and fail to see an option in the Preferences -> Compose window.
I am OK with UNIX Command line tasks if that is the only way to set this default.
Basically I have an alumni email redirection service, which is an address that never changes, even if I change ISP. That way all my friends can use it an never change. However, they tend to use whatever ISP address is, not what I have asked them to use.
I want to force emails I send to default to my alumni address when my friends reply, not my ISP address. I want control over this.Confused Once Again wrote:
I want to set up my email composition with a default [email protected] address in the "Reply-to" field that is different from my ISP. How do I configure mail to set this default?
Email preferences --> select Account --> Account Information tab --> Email address.
The Email address setting supplies the "from" mail address in a sent email for that account.
I been doing this for years (well in Eudora but it works in Mail too) since my return address is a mail forwarding service. That lets me switch ISP's and no one is ever the wiser. I just change the forwarding service "pointer" to point to my new ISP. But everyone else see sees the same "from" address as it's always been. -
How to give the no of lines per a page in script
hi
could anybody tell me
how to give no of lines per page in scripts.
actually i want to set n lines per page in scripts.
could anybody suggest me..
thanx.
kals.Hi,
You can not set the No of Lines per page in the SCRIPT programetically, but here is the way to count the lines per page and you can restrict the lines per page also, just count the Total lines of all winodws in that page, lines mean The length of the windoe, lets say all the window lenghts are 20cm, then 20 lines will be printed. and you can convert this lenght cm to Lines also in the script. by converting the lenght Cm tyo lines you can count and reqtrict ..
Regards
Sudheer
Maybe you are looking for
-
E72 : Unable to configure email post 071.004 firmw...
My emails on e72 were working perfectly fine before this upgrade. but post upgrade, I was unable to recieve my emails. So I removed the accounts and tried to reconfigure them. But the configuration wizard doesn't get past the 'Detecting Email Setting
-
Pricing Procedure in Scheduling Agreement
Dear All, Can we have calculation schema for Scheduling Agreement? the calculation schema in PO is working ok. the calculation schema is assigned in vendor master to vendors. but when the same vendor is used in Scheduling Agreement, not all the
-
Hello, I'm in trouble with my motherboard KT6 Delta FISR : drivers are installed, configured, everything is ok, music is working, video CD also, but no sound if I try to run a DVD !?!? No mean to get sound on the analog output. Tried everything but c
-
Lumia 925 to nokia xl dual sim.
i like to transfer my contacts/sms/etc from my nokia lumia 925 to nokia xl dual sim, is it possible? if can, how? at least i want the sms.... thanks.
-
Hello I would like to know if you can somehow set the number of copies printed per customers Ex Customer A : 1 copie Delivery Customer B : 2 copies Delivery