I wish to create a folder on a unix server B from my windows box using windows batch script.
Below is my windows batch script.
At plink command i get logged on to ServerA and get auto ssh to Unix ServerB.
Post auto-login to ServerB the command [mkdir %mydir%] does not get executed on serverB from my Windows batch prompt. I have to manually type the mkdir command from my windows DOS shell inorder for the folder to be created on ServerB.
Can you help the mkdir command in my windows batch script to get auto executed on ServerB ?
Last edited by mohtashims; 10-10-2012 at 08:08 AM..
Post auto-login to ServerB the command [mkdir %mydir%] does not get executed on serverB from my Windows batch prompt. I have to manually type the mkdir command from my windows DOS shell inorder for the folder to be created on ServerB.
This is to be expected. A script runs on a certain system. If you i.e. issue
then you expect "cmd1" to get executed, then "cmd2", then "cmd3". "plink ..." is such a command and gets executed - and as soon as it terminates, then next command gets executed.
If you want to remotely execute the last command, remove it from the script. Then, depending on the functionality of this "plink" facility:
Put a parameter to the plink-command to instruct it to execute the command remotely. With "ssh" you can do that, even on Windows.
Put the necessary command into a script at the remote system. You'd still have to execute that script per hand or using the method above.
Install a "rexec" (remote exec) or "rsh" (remote shell) feature (or however this may be called in Windows, i have no idea), which is designed exactly for your purpose. Be advised that this is considered a security problem in most productive environments, which is why ssh has an analogous facility built in. That does the same but in a more secure way.
If i instruct it to execute the command remotely then it says "Authentication Failed" becoz as I provide the password for Unix ServerA it auto switches to Unix ServerB which is where rather than prompting for the password for the second time for unix ServerB it reads the command
and passes the command as an input to the password.
I hope you now understand what the problem is.
Now, can you please help me get the mkdir command somehow executed on unix ServerB from my windows ?
If "plink" can't be brought to do what you want consider alternatives. Use "ssh" or whatever else i already told you.
have a look at the startup files for your unix server too: it isn't usualy to immediately ask for a password for another machine. If you have an automatic connection to a remote system in some profile you should remove it, but this has nothing to do with the script at hand, just with the configuration of the remote system.
Anyway, this is all guessing wildly in the dark until you show any relevant information. Trace the process of running he script thoroughly *on both systems* and present *any* outcome here (unfiltered, instead of telling us about what you think the output might have been meaning).
This might get solved the problem, anything else is ultimately idle chit-chat.
If i instruct it to execute the command remotely then it says "Authentication Failed" becoz as I provide the password for Unix ServerA it auto switches to Unix ServerB which is where rather than prompting for the password for the second time for unix ServerB it reads the command
and passes the command as an input to the password.
plink can take the password as a parameter, you don't have to jam it into stdin.
You should be checking the commands you run for success or failure, anyway.
plink can take the password as a parameter, you don't have to jam it into stdin.
You should be checking the commands you run for success or failure, anyway.
The problem with this is, I am using Soft Token and the random password gets generated every 1 minute and the same password cannot be used twice.
It uses the first password for login to unix server A, and then expect a new random generated password for unix server B which I am not sure how to pass using plink along with the mkdir command.
the ssh option with plink does not do anything different.
It logs me in to unix ServerA and then to unix ServerB where is prompts for the password. Then I am into the unix shell from my windows shell as seen in the snap below.
Hi everyone,
I've below windows batch script which is used to filter the file contents line by line and assign the matched values to the variables in for loop.
for /F "tokens=1,3 delims=:" %%A in (%LOG_DIR%\PM_IS_workflow_status.log) do (
set "ATTR_NAME=%%A"
if /i "!ATTR_NAME!" EQU "Folder"... (1 Reply)
Hi all,
i need to run a shell script on remote server. I have created file .bat file in windows server with following code,
c:\Users\Desktop\putty.exe -ssh -pw password user@server ./script.sh
i need to run the script.sh in my remote server
Above command is not working, any... (4 Replies)
Good morning all. I have been running into a problem running a simple gawk script that selects every third line from an input file and writes it to an output file.
gawk "NR%3==0" FileIn > FileOut
I am attempting to run this command from a batch file at the command line. I have several hundred... (6 Replies)
Hi Experts,
I have a requirement where i need to setup a batch job which runs everymonth and move the pdf files from unix server to windows servers.
Could some body provide the inputs for this.
and also please provide the inputs on how to map the network dirve in the unix like that... (1 Reply)
Hi,
When I run the below script in UNIX it's throwing syntax errors. Actually it's a windows batch script. Could anyone change the below Windows Batch script to UNIX shell script...
Script:
REM :: File Name : Refresh_OTL.bat
REM :: Parameters : %1 - Region
REM :: : %2 - Cube Type
REM ::... (5 Replies)
Hi everyone, let me get straight to the points.
My manager wants to execute a remote batch file (on a Windows server) from a UNIX Machine, does anyone know if this is possible and what packages would be needed?
Thanks
p.s. Sorry i cant give OS specifics, we use most UNIX's; AIX, Solaris,... (5 Replies)
I just installed Windows Services for Unix. I want to create a ksh program and schedule it using the Windows scheduler. How would I go about doing it?
What would the command line look like?
Do I always have to be in a ksh shell to run the batch program even if it is not scheduled?
... (3 Replies)
I am using awk in my .ksh script but when I am trying to run in windows
its not recognising awk part of the ksh script , even when I changed it to gawk it does not work, this is how my .ksh and .bat files look like.
thanx.
#!/bin/ksh
egrep -v "Rpt 038|PM$|Parameters:|Begin |Date: |End... (1 Reply)
Hi all,
I'm working on Windows, connecting to my Unix account by different ways: by FTP opening files in UltraEdit32, by mapping drive to browse, by Exceed or Telnet to compile at Unix account. Actually, that is what I would like to change:
I'd like to make a batch file which would connect to... (7 Replies)