I have a ftp script there I want to store the o/p of the below command:
Now the problem is that when I fire this command. Then it gives o/p as:
but when in the script I fire the same command as below:
then it doesn't store the error i.e.
but stores only
Can anyone please suggest how store the error in the variable as well?
The problem is that I don't want black or white scenario......
As I wouldn't be sure of the exact file name; I want to capture it so I had to use something like this
else I would just used
But when it successfully finds the file on the FTP server then the variable has the below value:
And after that I get the exact name of the file as below:
Oh no! I cannot change the way the FTPing is done in the script.....it's already in Production env and because of some environment issues we had to fix a bit here and there.
So I cannot change from "sftp" to "ssh" & "scp" sorry! But can tweak few unix commands to work this out!
And also when I do this:
It shows success i.e. (fetch_file_succ=0) even when there's a failure!!
If I understood what you want, you can use both to solve your problem.
Something like:
But, you are saying that you cannot trust sftp's return code.
Can you post the error SFTP is returning to you?
In the past, all my routines were based on FTP, but I could not trust on the return code, so I redirected its output to a file and did some validations on it and that's why I went to scp.
I had some sftp issues, that, even when the transfer was ok, it returned an error code != 0, just because I issued a mkdir inside the batch file, and the directory I was creating already exist in the remote host.
Have you tried to raise the sftp logging level?
I am going to do a test and post the result here.
---------- Post updated at 13:16 ---------- Previous update was at 13:07 ----------
Ok!
If the above helps, you can do the following to validate the error:
Hi All,
I want to run multiple sql queries and store the data in variable but i want to use sql command only once. Is there a way without running sql command twice and storing.Please advise.
Eg :
Select 'Query 1 output' from dual;
Select 'Query 2 output' from dual;
I want to... (3 Replies)
I have a below syntax its working fine...
var12=$(ps -ef | grep apache | awk '{print $2,$4}')
Im getting expected output as below:
printf "%b\n" "${VAR12}"
dell 123
dell 456
dell 457
Now I wrote a while loop.. the output of VAR12 should be passed as input parameters to while loop and results... (5 Replies)
I'm working on a script in which gives certain details in its output depending on user-specified options. So, what I'd like to do is something like:
if
then
awkcmd='some_awk_command'
else
awkcmd='some_other_awk_command'
fi
Then, later in the script, we'd do something like:
... (5 Replies)
Hi,
My aim is to get the md5 hash of a file and store it in a variable.
var1="md5sum file1"
$var1
The above outputs fine but also contains the filename, so somthing like this 243ASsf25 file1
i just need to get the first part and put it into a variable.
var1="md5sum file1"... (5 Replies)
Hi all,
I am new to Linux/shell scripting having moderate knowledge.
In my script, I need to get execution time of a command (say 'ls') in mili seconds level. For this i tried using "time" command to retrieve the total execution time in milli seconds. But, the problem is that, how to save... (9 Replies)
Hi all,
I m new to this forum.
I ma facing onei issue.
I have something like this:
length= wc -l < b2| awk '{print $1}'
where b2 is filename having detauls like:
cat b2
abc1
abc4
xyc3
sbdghf4
but when I do echo "$length" it displays nothing
Also I am using awk to overcome... (4 Replies)
Hi Everyone,
I have a code which requires to be stored in different variables and I am achiving it like this.
HOST=`echo $RMP | cut -f2 -d:`
NAME=`echo $RMP | cut -f3 -d:`
DIR=`echo $RMP | cut -f4 -d:`
TYPE=`echo $RMP | cut -f5 -d:`
Is there any other way of storing value... (2 Replies)
The following program takes two command line arguments.
I want the second argument (fileCount) to be stored/printed as a int value. I tried my best to typecast the char to int (check the printf statement at last) but is not working...the output is some junk value.
This program is in its... (3 Replies)
how would i go about storing this command in a variable
echo "$LINE" | awk -F"|" '{print $1"|"$2"|"$3"}'
i have tried FOO = ${command up there} but receive the error FOO: not found
aswell as a couple of other attempt but no luck (2 Replies)
For whatever reason I cant seem to fix my syntax to do the following. I want to run a grep and count how many instances come up and store that number in a variable but I keep erroring out. Here's my code in bash:
number=grep blah file.txt | wc -l (1 Reply)