10-27-2008
How to create file on Linux using environment variable in the dirpath
Hi all,
I am running a Java program on a Linux server in which I read in a base directory path from the *.properties file. During processing, I build a unique file name and create a file to save data, concatenating the directory path and the file name. Works fine, except that I now need to modify this code to accept an environment variable as part of the directory path (previously it was uniquely specified). I've experimented with various ways of quoting - no luck. I'm sure there's a simple syntax to permit this, but so far I've been unable to find it.
File creation statement looks like this:
File uploadFile = new File(baseDir + newFileName);
where baseDir has been read in from the properties file and is equal to
$MYFILEDIR/reports/
The file creation is failing.
Can anyone tell me what syntax can I use in the input that would allow me to create the file in the expected directory? Thanks so much.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I have say two programs
File1:
echo Enter A's Value
read A
export A
File2:
while
do
echo $A
sleep 5
done (1 Reply)
Discussion started by: pbsrinivas
1 Replies
2. IP Networking
could anyone Explain me with how the linux o/s keeps track of file
updates in network environment? for example, assume that more than one
computer is connected to network (with linux in all of them). if an
user say 'X' logged into terminal 1 and created a file with the name
of 'temp.txt'. The... (1 Reply)
Discussion started by: pjchoudary
1 Replies
3. Filesystems, Disks and Memory
could anyone Explain me with how the linux o/s keeps track of file
updates in network environment? for example, assume that more than one
computer is connected to network (with linux in all of them). if an
user say 'X' logged into terminal 1 and created a file with the name
of 'temp.txt'. The... (1 Reply)
Discussion started by: pjchoudary
1 Replies
4. Shell Programming and Scripting
I've searched Google and now this forum. Best guess is my search fu is not good (and it probably isn't). The Google search did bring me here.
Background
I have a number of Korn Shell scripts who all use one of 3 values for an environment variable used in the backup system.
On occasion one or... (8 Replies)
Discussion started by: WolfBrother
8 Replies
5. Shell Programming and Scripting
Hi,
i have the following env variable. currently i am exporting variable in the same script file. but i need this is in a text file and the scripts need to export this variable from the text file.
can you please suggest me. is it possible.
export... (6 Replies)
Discussion started by: rsivasan
6 Replies
6. Shell Programming and Scripting
I'm trying to make a sed substitution where the substitution pattern is an environment variable to be expanded, but the variable contains a "slash".
sed -e 's/<HOME_DIRECTORY>/'$HOME'/'This gives me the following error:
sed: -e expression #1, char 21: unknown option to `s'Obviously this is... (2 Replies)
Discussion started by: Ilja
2 Replies
7. UNIX for Dummies Questions & Answers
I want to set a enviroment variable
VDC_DIR to a particular directory.
I am doing it as
export VDC_DIR=/abc
it gets set but when i logout and do relogin than its not there.
one way could be setting it in .profile file.
but i have seen it on another box where it is not present in... (2 Replies)
Discussion started by: Jcpratap
2 Replies
8. Shell Programming and Scripting
Hi,
I an having some environment variables exported and the variable name is present in the file. But its not resolving with following commands. Can someone throw some light.
db $ grep -v "^#" TD_FWK_NUCLEUS.dbc | grep -v "^$" | xargs -i echo {}
wb_bin: ${TD_FWK_NUCLEUS_DBC_WB_BIN_TAG}
I... (3 Replies)
Discussion started by: Mohammed Rafi
3 Replies
9. Shell Programming and Scripting
Hi,
I meet an problem that it cannot change Terminal environment variable in a perl or bash script.
This change can only exist and become effective in script lifetime.
But I want to make this change take effect in current opened Terminal.
In our view, the thought seems to be impossible,
As... (9 Replies)
Discussion started by: weichanghe2000
9 Replies
10. UNIX for Dummies Questions & Answers
I know that I can do this in bash
ver=${VERSION:-$DEFVERSION}
so ver is $VERSION if it's set but $DEFVERSION if $VERSION isn't set
I want to do the same thing as a macro in a Makefile and can't get it to work - maybe something like...
VER=$(shell ${$(VERSION):-$(DEFVERSION)})
Any help... (1 Reply)
Discussion started by: JerryHone
1 Replies
LEARN ABOUT SUNOS
imqadmin
imqadmin(1M) System Administration Commands imqadmin(1M)
NAME
imqadmin - launch the Message Queue administration console
SYNOPSIS
/usr/bin/imqadmin [-javahome path]
/usr/bin/imqadmin -h
/usr/bin/imqadmin -v
DESCRIPTION
imqadmin launches the graphical user interface application that performs most Message Queue administration tasks. These tasks include man-
aging broker instances (including physical destinations) and administered objects.
OPTIONS
The following options are supported:
-h Display usage help. The application is not launched.
-javahome path Specify a path to an alternate Java 2 compatible runtime.
-v Display version information.
ENVIRONMENT VARIABLES
The following environment variables affect the execution of this command:
IMQ_JAVAHOME Specify the Java 2 compatible runtime. When this environment variable is not set it defaults to /usr/j2se.
EXIT STATUS
The following exit values are returned:
0 Successful completion.
>0 An error occurred.
FILES
$HOME/.imq/admin/brokerlist.properties
Contains user settings, a list of broker instances being managed.
$HOME/.imq/admin/objectstorelist.properties
Contains user settings, a list of object stores being managed.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWiqu |
+-----------------------------+-----------------------------+
SEE ALSO
imqbrokerd(1M), imqcmd(1M), imqdbmgr(1M), imqkeytool(1M), imqobjmgr(1M), imqusermgr(1M), attributes(5)
Sun Java System Message Queue Administrator's Guide
SunOS 5.10 11 Mar 2004 imqadmin(1M)