How can I pass arguments to a command that is run via psexec.exe? - autoit

I am running the following command format:
PsExec.exe -i -s \\\\ip -u username -p password "\\\\shared\driver\path\autoitscript.exe" "\\\\shared\driver\path\car.jpg"
The exe file takes in a file path and enters the path in a file upload window. The exe file is an AutoIt script (.au3 file converted). The script uses ControlSetText to enter the file path in the upload window. I can see the exe file being run on the remote machine, but for some reason the file path is not being entered. Is there something wrong in the way i execute the psexec command? Locally the script executes correctly.

I was using ControlSetText to send the file path into the upload window. That did not work. Instead use ControlSend or Send.

Related

Short cut for invoking shell script in unix

I have below two file to start and stop my spring-boot application. Is it possible to have this installed as server etc in unix? so that I can just type start app or stop app to start or stop my application from any location?
startApplication.sh
stopApplication.sh
You can always define alias in your bash, do as below:
sudo vim ~/.bashrc
go at the end of file and add this line
alias start-app='bash /<path-to-script>/startApplications.sh'
save and exit and resource it with source command
source ~/.bashrc
now if you type in your terminal start-app it will execute your script. create one for stop-app too.

Get system directory path

I want to upload an image file using an AutoIt script:
WinWaitActive("Open")
Send("D:\sprint8execution\gGastro-mvn\tmp.png")
Send("{ENTER}")
How to give the system-defined path in the script so that if the script runs on any other machine it goes to applicable directory and fetches the image from there?
Have a look to the AutoIt macros. #ScriptDir is the directory that includes the current running script.

Added Alias to .bashrc but no results

I added an alias (alias homedir='cd /export/home/file/myNmae'
) to .bashrc in my home directory and restarted the session. When I run the alias it says homedir: command not found.
Please advice.
This is because .bashrc is not sourced everytime, only for interactive non login shells .bashrc is sourced.
From the bash man page.
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/pro-
file, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the
first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.
When a login shell exits, bash reads and executes commands from the files ~/.bash_logout and /etc/bash.bash_logout, if the files exists.
When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists. This may be inhibited by using the
--norc option. The --rcfile file option will force bash to read and execute commands from file instead of ~/.bashrc.
i found the solution - i added it to the .profile file and restarted the session - it worked

changing directory access using ICACLS.exe at runtime

I have the following syntax to change the directory access permission of the LOGO folder in the web application
ICACLS D:\Workspace\SampleProject\LOGO /grant "IIS_IUSRS":(OI)(CI)F.
This works fine if the application is deployed on local IIS, If the web application is hosted on some external server i am not sure what will be the exact path of the LOGO folder,that means cant hard code the path.
so i have written a console application , which gives me the complete path of logo folder on the server and the path is written to sample text file.
my question is their any way to substitute the path "D:\Workspace\SampleProject\LOGO" with the path obtained from text file at runtime ?.
As far as I understand from reading your question and comments, you have a text file with the path of the LOGO folder and you want to run icacls.exe from a batch file to set the folder permissions.
Say, your text file is named path_to_logo.txt and contains a single line with the path. Then the following batch script will do the job:
for /F %%l in (path_to_logo.txt) do ICACLS %%l /grant "IIS_IUSRS":(OI)(CI)F
for /f will loop through all lines in a file (and you have just one), assign the current line to a variable %l and execute what follows the do keyword.

send output to file from within shell script

I'm creating a script for users to run. I need to redirect the output to a file I'm creating from inside the script (hostname-date).
I have all the pieces except for how to copy the output of the script from inside the same script. All the examples I can find call the script and > it into the log, but this isn't an option.
-Alex
Add the following at the top of your script:
exec &> output.txt
It will make both stdin and stderr of the commands in the rest of your script go into the file output.txt.
exec in bash allows you to permanently redirect a FD (say, stdout) to a file.
A shell that calls a shell.
Have the first shell create the variable (hostname-date)
and call the second shell redirecting the output to the file.

Resources