Redirect Standard Error to /dev/null is not working.
Hello.
When I run a .ksh that contains the command below, and there is no file available in the source location the "FILE_NAME_*.CSV not found" error is still being displayed.
.
This is interfering with the rest of the script, as it is not exiting as required, and is continuing to the next command (See below).
Can anyone advise what I am doing wrong with the redirection? Basically If there are no files available, I need to echo the warning and exit the script successfully.
Thanks in advance.
---------- Post updated at 02:36 PM ---------- Previous update was at 12:07 PM ----------
Good you found a fix by yourself! Still, for e.g. later reference, these were the errors in your first script, which you did not correct but circumvent:
a) put the redirection inside the command substitution.
b) save the exit status for later use before printing $FILEN (which will overwrite status)
b) save the exit status for later use before printing $FILEN (which will overwrite status)
This is correct, but even
Will show only the exit status of the last command, which is a variable assignment. The exit code will be that of var=someting, not that of any of the commands.
Btw., you might want to put quotes around the subshell, otherwise the script might break if the result of the subshell contains whitespace. For example:
Will first assign "abc" to "$var", then try to execute "def", which will fail. Use:
. . .
Will show only the exit status of the last command, which is a variable assignment. The exit code will be that of var=someting, not that of any of the commands.
. . .
Hmmm - sounds reasonable, but (linux, bash):
while
So the 2 would be the ls' exit status, wouldn't it?
I'm using an text-to-speech synthesis in a script, and I need to redirect it's output to /dev/null
how can I do that ? And how to redirect the stream to his normal output then (sound card ) ?
thankx (2 Replies)
I apologize if this question has been answered else where or is too elementary.
I ran across a KSH script (long unimportant story) that does this:
if ; then
CAS_SRC_LOG="/var/log/cas_src.log 2>&1"
else
CAS_SRC_LOG="/dev/null 2>&1"
fithen does this:
/usr/bin/echo "heartbeat:... (5 Replies)
Hi Guru's,
I am trying to test the network speed or load by this command.
but getting error " Not Connected ". Could you guys please help.
ftp> put "|dd if=/dev/zero bs=8k count=1000000" /dev/null
Not connected.
Please use
code tags! (9 Replies)
How are these two different? They both prevent output and error from being displayed. I don't see the use of the "&"
echo "hello" > /dev/null 2>&1
echo "hello" > /dev/null 2>1 (3 Replies)
Hey, I'm completely new at this and I was wondering if there is a way that I would be able to redirect the log files in a directories standard output and standard error into and excel spreadsheet in anyway?
Please remember don't use too advanced of terminology as I just started using shell... (6 Replies)
Hi
i am running oracle database import through a script and script scans the import log to see if there are any errors.
Now the porblem is that when i run the script the import log appears on the screen even if i direct the output of import to /dev/null.
imp "'/ as sysdba'"... (5 Replies)
Hi, Anyone can help
My solaris 8 system has the following
/dev/null , /dev/tty and /dev/console
All permission are lrwxrwxrwx
Can this be change to a non-world write ??
any impact ?? (12 Replies)
Working in a bash environment, in the following example, how do I direct the error message that putting in an invalid flag (-j for example) would normally produce to dev/null?
while getopts "abcd" opt
do
case "$opt" in
i) a etc ;;
r) b etc ;;
f) c etc ;;
v) d... (7 Replies)
Hi,
I have a script as follows:
#!/bin/sh
nohup ./my_program >& /dev/null &
However, i get a "Generated or received a file descriptor number that is not valid" whenever I run it.
running the command up in prompt is ok though.
if i change the first line to #!/bin/csh
i get a then:... (4 Replies)