SFTP passing variables date


 
Thread Tools Search this Thread
Operating Systems Solaris SFTP passing variables date
# 1  
Old 03-31-2011
SFTP passing variables date

Hi,

Anyone can help me on how to solve my problem not getting the actual $DATE saying . Here my scripts;
Code:
#!/bin/sh
DATE='20110331'
sftp -oUserKnownHostsFile=/.ssh/known_hosts -oIdentityFile=/.ssh/id_rsa -b /source/transfer.sh server1@sftp.com  <<EOF

#tranfer.sh
put /getdir/tranx_$DATE.txt
quit
EOF

error saying : File "/getdir/tranx_$DATE.txt" not found

But the file was there : /getdir/tranx_20110331.txt


Thanks in Advance,
FSP

Last edited by jim mcnamara; 03-31-2011 at 07:40 AM.. Reason: ...
# 2  
Old 03-31-2011
try exporting the variable

export DATE='20110331'
# 3  
Old 03-31-2011
looks like transfer.sh contains the sftp command which are to be used by sftp in batch mode.
Variables in tranfer.sh will not be expanded as sftp would treat this as text file with the list of commands in it.

You can try to generate the command file from within your script and the try to use like... something like..

Code:
 
#!/bin/sh
DATE='20110331'
echo "put /getdir/tranx_$DATE.txt
quit
EOF" > tranfer.sh

sftp -oUserKnownHostsFile=/.ssh/known_hosts -oIdentityFile=/.ssh/id_rsa -b /source/transfer.sh server1@sftp.com  <<EOF

# 4  
Old 03-31-2011
Quote:
Originally Posted by xoops
looks like transfer.sh contains the sftp command which are to be used by sftp in batch mode.
Variables in tranfer.sh will not be expanded as sftp would treat this as text file with the list of commands in it.

You can try to generate the command file from within your script and the try to use like... something like..

Code:
 
#!/bin/sh
DATE='20110331'
echo "put /getdir/tranx_$DATE.txt
quit
EOF" > tranfer.sh

sftp -oUserKnownHostsFile=/.ssh/known_hosts -oIdentityFile=/.ssh/id_rsa -b /source/transfer.sh server1@sftp.com  <<EOF


Hi Xoops,

Can you please elaborate. i try that but still can't found error

Thanks


Last edited by fspalero; 03-31-2011 at 12:04 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing -f with rm command in sftp

Is there any way I can pass -f with rm command in sftp? If I use it it treats -f as a file name to be removed. sftp> rm -f abcd Couldn't stat remote file: No such file or directory Removing /home/sdesai/-f Couldn't delete file: No such file or directory sftp> "rm -f" abcd Invalid... (2 Replies)
Discussion started by: Soham
2 Replies

2. Shell Programming and Scripting

Passing awk variables to bash variables

Trying to do so echo "111:222:333" |awk -F: '{system("export TESTO=" $2)}'But it doesn't work (2 Replies)
Discussion started by: urello
2 Replies

3. Shell Programming and Scripting

Passing Variables

I have below data: DAY1=10202013 I am trying below but not getting the desired output: COUNT=1 DATE=DAY$COUNT echo "Date is $DATE" However output I am getting is: Date is DAY1 I wanted the output as: Date is 10202013 I tried following as well: DAY1=10202013 COUNT=1... (3 Replies)
Discussion started by: rockyr1985
3 Replies

4. UNIX and Linux Applications

SFTP Passing without DSA Key check

Hi, I am trying to connect through SFTP. Though the DSA 2048 public key is installed in the server machine, the connection is established only with password authentication! When i turn off password authentication in sshd_config file the connection is not working. Please advise, Best... (0 Replies)
Discussion started by: Maharajan
0 Replies

5. UNIX for Dummies Questions & Answers

SFTP Passing without DSA Key check

Hi, I am trying to connect through SFTP. Though the DSA 2048 public key is installed in the server machine, the connection is established only with password authentication! When i turn off password authentication in sshd_config file the connection is not working. Please advise, Best... (0 Replies)
Discussion started by: Maharajan
0 Replies

6. UNIX and Linux Applications

SFTP without passing the password

Hi All, I am trying to do SFTP without passing the password. I did it by generating the Key pair on both source and destination servers but the problem is My script is running with BATCHADM user whereas I am doing SFTP using another username (sftp user1@destinationServer) due to which it is... (3 Replies)
Discussion started by: kaurr06
3 Replies

7. Shell Programming and Scripting

Passing 2 variables

Hi All, I need to pass 2 variables name 'vamskt' and 'vamsi'. Here is my question: delete from gpi.usergroup where usg_user_id in ('vamskt'); delete from gpi.userroles where uro_user_id in ('vamskt'); delete from gpi.user where usr_id in ('vamskt'); insert into gpi.user... (3 Replies)
Discussion started by: tvamsikiran
3 Replies

8. UNIX for Dummies Questions & Answers

ISSUE on SFTP fucntion ,parameter passing!

Hi Everyone!! Hey i created a SFTP function to FTP the file from unix to Linux. I need to FTP the 48 files from unix to linux. IP=$1 Userid=$2 Prikeypath=$3 SrcPath=$4 DstPath=$5 Files=$6 BATCHFILE=sftp.batch.$$ LOGFILE=sftp.log.$$ #Compose batch file & pass as argument to the... (1 Reply)
Discussion started by: bobprabhu
1 Replies

9. Shell Programming and Scripting

Passing variables: sftp using -b batchfile

Hi All, I have created a script for an sftp transfer that works without a date variable being passed, I want it to work with a date variable being passed. So, my initial script, mainsftp.sh, looks like this: ----------------------------------------------------------------------- #... (1 Reply)
Discussion started by: j_miller
1 Replies

10. Shell Programming and Scripting

passing variables

Hi, Is there any way to pass variable to a sed script.For awk we have -v option.like that do we have any way to pass variable to a sed script from a awk script or from normal script? Thanx, sounder (1 Reply)
Discussion started by: sounder123
1 Replies
Login or Register to Ask a Question