Sign in to follow this  
Followers 0
superbosu

Pass variable to a command run

10 posts in this topic

Hi all!

this is my problem:

I want to run this command from AutoIt with "Runwait" but I don't know how to pass the variable to the command

$CR = 'GEDK123456'

PSexec.exe \\10.30.1.181 -u camp-sap\user -p password I:\usr\tp.exe import $CR GEP client=100 u1236 pf=\\10.30.2.15\sapmnt\trans\bin\TP_DOMAIN_GED.PFL

is there a way to run this command from Autoit and to show the result? HELP me please

tnx

Share this post


Link to post
Share on other sites



PSexec.exe \\10.30.1.181 -u camp-sap\user -p password I:\usr\tp.exe import $CR GEP client=100 u1236 pf=\\10.30.2.15\sapmnt\trans\bin\TP_DOMAIN_GED.PFL

That line looks like gibberish, could you please re-format it so I, or anyone else, can help you better?

shanet


[font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS:
%programfiles%/AutoIt3/autoit3.chm

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

What about this:

$CR = 'GEDK123456'
$command = @ComSpec & " /c " & "PSexec.exe \\10.30.1.181 -u camp-sap\user -p password I:\usr\tp.exe import " & $CR & " GEP client=100 u1236 pf=\\10.30.2.15\sapmnt\trans\bin\TP_DOMAIN_GED.PFL"
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $command = ' & $command & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
;~ $pid = RunWait( $command)

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

shanet,

If you have no idea what a post is about then please just keep quiet and do not jump in, as you so often do, with inane comments. :P

superbosu,

Welcome to the AutoIt forum. :x

I see you already have a sensible response from UEZ so I will not bother to repeat it as is exactly what I was going to suggest. :shifty:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Hi all!

this is my problem:

I want to run this command from AutoIt with "Runwait" but I don't know how to pass the variable to the command

$CR = 'GEDK123456'

PSexec.exe \\10.30.1.181 -u camp-sap\user -p password I:\usr\tp.exe import $CR GEP client=100 u1236 pf=\\10.30.2.15\sapmnt\trans\bin\TP_DOMAIN_GED.PFL

is there a way to run this command from Autoit and to show the result? HELP me please

tnx

Sorry I will try to explain this better :x

this is my variable

$CR = 'GED123456'

Psexec.exe is an exe on c:\ that runs an exe on a remote pc (it needs always some parameters)

tp.exe is an exe on remote pc and it needs also parameters

for example if I run this command from dos works:

C:\PSexec.exe \\10.30.1.181 -u camp-sap\user -p password I:\usr\tp.exe import GED123456 GEP client=100 u1236 pf=\\10.30.2.15\sapmnt\trans\bin\TP_DOMAIN_GED.PFL

I want to put run this entire command line with RunWait ("C:\PSexec.exe \\10..... $CR GEP ... ") but I don' t know how to pass the $CR variable on the command line inside Runwait function.

is this possible?

Share this post


Link to post
Share on other sites

Hi and thanks for the fast answer :P

I ll try this and let you know if it works well :x

Share this post


Link to post
Share on other sites

HI all! it works! :x tnx a lot for the support

Now I have another question, is there a way to execute also the command line "echo %ERRORLEVEL% >> %USERPROFILE%\desktop\log.txt" on $command ?

or there is a way to show %ERRORLEVEL% of the execution $command.

I tried @error but it send back 0 all the time.

Share this post


Link to post
Share on other sites

In the example of UEZ the $pid (remarked) should contain the ERRORLEVEL....

RunWait (Docu)

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Try not to make a habit of reviving old threads such as this, if you have a problem then create a new post please. Thanks. Plus it appears the question was answered.

Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0