Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

skmaeda

Thank you! I had some troubles but in the end I did it!
skmaeda

Put command uploads file with authenticated user

Hello,
I've created a script that needs to launch some commands, delete some log files, upload a file and then some other commands.
I'm logging in with one user, but I'm changing the user with the Shell option.
The problem is that the uploaded file's owner is the one I log in, not the one I put in the sudo command.

This is my script:
option batch continue
option confirm off
open sftp://user1@123.456.789.123/ -hostkey="....." -privatekey=".....ppk" -rawsettings Shell="sudo su - user2"
lcd C:\DEPLOY\CELRI
call /home/user2/apache-tomcat-lispa-CELIACHIATO/server/bin/shutdown.sh 2>/dev/null
rm /home/user2/apache-tomcat-lispa-CELIACHIATO/server/logs/*.*
cd /home/user2/apache-tomcat-lispa-CELIACHIATO/server/webapps
rm celiacra.war
call whoami
rm celiacra
put celiacra.war
call /home/user2/apache-tomcat-lispa-CELIACHIATO/server/bin/startup.sh 2>/dev/null
close
exit

This is what I get when I use ll in that directory:
-rw-rw-r--  1 user1 user1 78467988 Sep 26 15:25 celiacra.war

Am I doing something wrong?
Thanks!