add sudo parameter to command line winscp

Advertisement

jsimmon
Joined:
Posts:
3

add sudo parameter to command line winscp

Hi,
I need to add "sudo su -" command to command line execution of winscp in order to put it in a batch file. I know how to accomplish that in GUI, but i need it in command line mode.
Looking at winscp.ini file I see this option in a saved session where sudo is enabled:
[Sessions\remoteUsr@remoteServer]
HostName=linuxdev04.servizi.infogroup.it
UserName=name
FSProtocol=0
LocalDirectory=C:%5C
RemoteDirectory=/opt/remoteUsr
Shell=sudo%20su%20-%20remoteUsr
Color=13408767
How can i add to "Shell=..." as a command line parameter? I don't want to use saved session for portability reason.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: add sudo parameter to command line winscp

jsimmon wrote:

How can i add to "Shell=..." as a command line parameter? I don't want to use saved session for portability reason.
There's no other way. I believe that using stored session in an INI file is portable.

Reply with quote

jsimmon
Joined:
Posts:
3

Re: add sudo parameter to command line winscp

Thanks for your reply.
I think that INI file portability is at least questionable, but I understand that at present that's it.
I hope in future versions you will add parameters to command line execution to enhance scripting capability of WinSCP, at least to match GUI's settings.

martin wrote:

jsimmon wrote:

How can i add to "Shell=..." as a command line parameter? I don't want to use saved session for portability reason.
There's no other way. I believe that using stored session in an INI file is portable.

Reply with quote

jsimmon
Joined:
Posts:
3

Re: add sudo parameter to command line winscp

Hi again,
I also tried to put sudo command as first statement in the script launched by
winscp.com user:pwd@host /script="transfer.txt":
with transfer.txt content as follows:
call sudo su - otherUser
cd lib
mkdir %1%
mv *.jar %1%
lcd %2%
put *.jar ./
exit

getting this result:
Automatic actions are disabled when URL address is provided on command-line.
Searching for host...
Connecting to host...
Authenticating...
Using username "user".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Error looking up user groups.
Command 'groups'
failed with return code 127 and error message
groups : command not allowed.
Reading remote directory...
Session started.

Instead, if I try doing the same with
winscp.com user:pwd@host
and then manually writing the command "call sudo su - otherUser" I get this error after 15 seconds delay:
Host is not communicating for more than 15 seconds. Still waiting...
Warning: Aborting this operation will close connection!
(A)bort:

Reply with quote

Advertisement

kidata
Joined:
Posts:
1
Location:
Germany

martin wrote:

You cannot execute commands that require user input.
Is it still not possible to send user inputs?

We also need to work with sudo and have to send the password, when it's asked for.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

kidata wrote:

Is it still not possible to send user inputs?

We also need to work with sudo and have to send the password, when it's asked for.
It's technically not possible. So it never will.

Reply with quote

lionking
Guest

I have this timeout too.

My sudo does not need user input, why i have this timeout of 15 seconds?

What is the best workarround?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

lionking wrote:

I have this timeout too.

My sudo does not need user input, why i have this timeout of 15 seconds?

What is the best workarround?
Please attach a full log file showing the problem (using the latest version of WinSCP).

To generate log file, enable logging, log in to your server and do the operation and only the operation that causes the error. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you may email it to me. You will find my address (if you log in) in my forum profile. Please include link back to this topic in your email. Also note in this topic that you have emailed the log.

Reply with quote

Advertisement

MrWade
Guest

Did this get solved?

I have a script that calls "sudo su - username" which is password-less and has no user input. However, the script when executed (including on PLINK) shows "[YOU HAVE NEW MAIL]" and doesn't skip pass this point. Any ideas?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Did this get solved?

MrWade wrote:

I have a script that calls "sudo su - username" which is password-less and has no user input. However, the script when executed (including on PLINK) shows "[YOU HAVE NEW MAIL]" and doesn't skip pass this point. Any ideas?
Please start a new thread. Show us some logs, outputs and screenshots; and try harder explaining your problem.

Reply with quote

Advertisement

You can post new topics in this forum