Better HN
topnewbestaskshowjobs
Log inSign up

brewedDoritos

8 karma · joined Dec 25, 2023 (2y ago) · 5 submissions

Brewing Doritos since 1912
Submissions

comment 2y ago · link · parent

Point taken about rsync, but you are assuming incorrectly that I haven't read it and that I haven't tried batch mode, but it still failed to run under cron inside an expect script.

It's not my orgunit that manages the contract with the vendor. I will absolutely use paramiko instead of trying to explain a technical problem to two middle managers in another orgunit to take it up with a non technical person on the vendor side whenever they feel like it when my deadline ends at the end of the year

comment 2y ago · link · parent

> Avoid sftp and use rsync instead

I should have explored rsync better. I asked chatgpt some use cases and it made seem to be a bad fit because I needed to also delete some files on the destination machine. My prompt fu was probably a bit bad at the time.

> Avoid passwords and use keys instead .

The vendor only provides password authentication in this case

> If you really have to, there's always sshpass.

I´ve tried it, but sftp, when running under a cron script, detects that it is not running in interactive mode and does not issue the password prompt. The problem might have been caused by the TERM environment variable not being set as another reader suggested.

> And ssh -t to allocate a tty even if you are running without one. But this is seldom really necessary

I've used -o RequestTTY=force, but it also didn't work. Granted, it was close to 4 am and I might have missed a key aspect.

> first try harder do it the easy way.

Paramiko endep up being easier once I understood how to use the proxy command to interact with the company's http proxy.

comment 2y ago · link · parent

> If you would run it in the background "./program &" and then exited ssh it would also exit.

Just wondering... have you tried running it with nohup and in the background?

comment 2y ago · link · parent

I've actually tried script and expect, but they didn't work.

I had enabled the debug option on expect and I couldn't see the password prompt when the program ran under cron (i was redirecting the script output to a log file). It did appear when running on the prompt though.

I couldn't figure how the sftp program was determining that it was running under cron. I suspect that it was inspecting if stdin was connected to a terminal or not, but I gave up around 4 am.

comment 2y ago · link · parent

Recently I tried to use an sftp script created with expect that ran fine on the command line, but the same script failed to run under cron. I made sure that all environment variables were properly set, but sftp didn't ask me for a password. I think it might have been an issue with the absence of a tty

sshpass didn't work, ended up rewriting the whole thing in Paramiko ... only to find out it doesn't respect the http_proxy environment variable.

That was not a good day