Link to home
Start Free TrialLog in
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
Avatar of woolmilkporc
Flag of Germany image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of celtician


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!