简体   繁体   中英

Invocation command using SSH getting failed?

As per project requirement, i need to check the content of zip file generated which been generated on remote machine.This entire activity is done using automation framework suites. which has been written in shell scripts. I am performing above activity using ssh command abd execute unzip command with -l and -q switches. But this command is getting failed. and shows below error messages.

[SOMEUSER@MACHINE IP Function]$ ./TESTS.sh
    ssh SOMEUSER@MACHINE IP unzip -l -q SOME_PATH/20130409060734*.zip | grep -i XML  |wc -l
    unzip:  cannot find or open SOME_PATH/20130409060734*.zip, SOME_PATH/20130409060734*.zip.zip or SOME_PATH/20130409060734*.zip.ZIP.

    No zipfiles found.
    0

the same command i had written manually but that works properly. I really have no idea.Why this is getting failed whenever i executed via shell scripts.

[SOMEUSER@MACHINE IP Function]$ ssh SOMEUSER@MACHINE IP unzip -l -q SOME_PATH/20130409060734*.zip | grep -i XML  |wc -l
        2

Kindly help me to resolve that issue.

Thanks in Advance, Priyank Shah

when you run the command from your local machine, the asterisk character is being expanded on your local machine before it is passed on to your remote ssh command. So your command is expecting to find SOME_PATH/20130409060734*.zip files on your machine and insert them into your ssh command to be passed to the other machine, whereas you (I'm assuming) mean, SOME_PATH/20130409060734*.zip files on the remote machine.

for that, precede the * character by a backslash ( \\ ) and see if it helps you. In some shells escape character might be defined differently and if yours is one of them you need to find the escape character and use that one instead. Also, use quotes around the commands being passed to other server. Your command line should look something like this in my opinion:

ssh SOMEUSER@MACHINE_IP "/usr/bin/unzip -l -q SOME_PATH/20130409060734\*.zip | grep -i XML  |wc -l"

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM