Avatar of celtician
celticianFlag for American Samoa asked on

Error sending Unix command from Batch file over plink (asterisk issue)

Im having trouble sendin the next command over plink from a batch file, its an asterisk issue.

I can execute it directly with putty or winscp command mode obtaining the result i need, however since i need to handle the output filename i need to call it from a batch file and im getting an error.

This is the command i have on the batch file (it returns the file name i need) that should write the filename in a given txt file (filename_here.txt)

plink -P 22 -l username -pw password machine.extension "ls -alrt C*.TXT | tail -1 | awk '{print $NF}'" >> filename_here.txt 2>&1

The output should be


however this is whats written in my txt file:

C*.TXT: No such file or directory
Unix OSWindows Batch

Avatar of undefined
Last Comment

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

If i dont type in -p 22 the connection is not working, i dont know why, but i just know that by inputing 22 it works :)

I tried your suggestion and now its working, it wasn't looking in the directry i wanted.

Strange, do you know why is not entering directly that directory? just as a follow up, since your answer is correct :)

thank you!

plink does not enter the directory in question because it's not the "home" directory of "username".

Thx for the points!
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.