Operating System - Linux
1828186 Members
2569 Online
109975 Solutions
New Discussion

Re: trying to do a 'mv' command with ssh in batch

 
Roger Gallant
Occasional Contributor

trying to do a 'mv' command with ssh in batch

I have a script that runs the following command:
ssh idrobmr5@dc2c8w "mv /datastore/data/obmtestbst/reports/idr/sftp/out/* /datastore/data/obmtestbst/reports/idr/sftp"

I get the following: mv /datastore/data/obmtestbst/reports/idr/sftp/out/* /datastore/data/obmtestbst/reports/idr/sftp: not found
Yet files are there. This is run in a script within a if then statement. if I run the same command outside the if..then it works?

what am I missing?
6 REPLIES 6
Patrick Wallek
Honored Contributor

Re: trying to do a 'mv' command with ssh in batch

What if you give the full path to the mv command.

ssh idrobmr5@dc2c8w "/usr/bin/mv /datastore/data/obmtestbst/reports/idr/sftp/out/* /datastore/data/obmtestbst/reports/idr/sftp"
Roger Gallant
Occasional Contributor

Re: trying to do a 'mv' command with ssh in batch

Thanks for the quick answer but no go... it still give me the not found error
Steven E. Protter
Exalted Contributor

Re: trying to do a 'mv' command with ssh in batch

Shalom Roger,

. ~/.profile

This may get enough of an environment to make this work.

Or set the PATH variable to at least include the current location of the mv command.

As far as I know not found means one thing. Can't find the command dude!!!!

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Roger Gallant
Occasional Contributor

Re: trying to do a 'mv' command with ssh in batch


I have the mv dir already set up in PATH.
Denver Osborn
Honored Contributor

Re: trying to do a 'mv' command with ssh in batch

the shell reporting "not found" seems to be pointing to "mv /from/path/* /to/path" as a single command...

how exactly is the above command executed? can you cut/paste snippets from the script... etc?

also, to help troubleshoot... what happens if you replace "mv" with something like an "ls -l"? Does it change to "ls -l /from/path/* /to/path: not found"?

-denver

Roger Gallant
Occasional Contributor

Re: trying to do a 'mv' command with ssh in batch

Denver,

Basically this script is to perform two task, the first one is to sftp a string of files to the target server on the directory ending with /out, that is done without any problem. The second step is once the files have been sftp'ed they then have to be moved one up on the tree so that the process that will treat those files will have a complete file and not a file in transfer. Attach is a copy of the script

If I take the result of the move (variable resolve) and execute it outside the script (ie: ssh blablabla) is works