0

I am checking files at remote sever in /temp directory and storing the count of the files in a temp files and doing scp to local sever. When I am running below command on console, its running file but its not working in shell script.

ssh id@$remote_sever
cd /temp
ls  *.txt | wc -l > /temp/temp.txt
scp /temp/temp.txt infa_id@local_sever:/TEMP
exit
1
  • /temp/temp.tx sure not a typo? Commented Aug 29, 2018 at 10:34

1 Answer 1

2

You don't need a temporary file on the other machine. You can execute the command via SSH and then store the result locally:

ssh id@remote_server 'ls /temp/*txt | wc -l' > /TEMP/temp.txt
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.