Topic "add sudo parameter to command line winscp"

Author Message
jsimmon
[View user's profile]

Joined: 2010-08-16
Posts: 3
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:
Code:
[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.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
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.
_________________
Martin Prikryl
jsimmon
[View user's profile]

Joined: 2010-08-16
Posts: 3
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.

prikryl 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.
jsimmon
[View user's profile]

Joined: 2010-08-16
Posts: 3
Hi again,
I also tried to put sudo command as first statement in the script launched by
Code:
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
Code:
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:
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
You cannot execute commands that require user input.
_________________
Martin Prikryl
kidata
[View user's profile]

Joined: 2013-08-08
Posts: 1
Location: Germany
prikryl 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.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
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.
_________________
Martin Prikryl
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?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
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.
_________________
Martin Prikryl
MrWade

Guest


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?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
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.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License