Showing posts with label line. Show all posts
Showing posts with label line. Show all posts

Tuesday, March 20, 2012

Calling commands from the cmd prompt

I have a series of commands that I need to run which decrypt, unzip, and rename

They are all one line commands when entered on the cmd prompt, is there an easy way to do this in ssis or should i write an exe and call them from there?

Thanks

Look at the Execute Process Task.

Frank

|||Yes, but the execute process task will execute a program. Granted I could make that program cmd.exe, I stuck on how to make an execute process task that will open up cmd and make the calls that I want. I could write a .exe file that that I could then put in the execute process task, I'm just curious if there's a way to do it w/ out writing my own script.exe file.

Thanks|||

Yeah Frank is correct on this one. The execute Process task shells to a command prompt automatically for you an dissues pkunzip or whatever tool you're using to decompress the file. The Script task in this case would be an overkill. You can make the Execute Process task typically call PKunzip.exe in the command (make sure you point to the full path) then the argument would be the file name and any switches for override.

--Brian

|||I'm using gzip to decompress files.

the command I'd like to run is gzip -dc filetounzip > filenametosaveto

I'm having no problem running everything before the ">" character. This normally pipes the output to location filetosave to. Without the filenametosave to it dumps the output to the standard out.
I tried to put the filenametosave to in a variable in the standardoutputvariable property w/ no avail. The reason I'm using gzip is because I'm unzipping a .gz file.

Thanks|||

you should use an expression for your argument property.

Frank

|||I have, when I do I get the following error

Error: 0xC0029151 at Positions Unzip Task, Execute Process Task: In Executing "C:\Program Files\GNU\Gzip\gzip.exe" "-dc F:\location\20060831.filename.gz.file > F:\location\test" at "", The process exit code was "1" while the expected was "0".
Task failed: Positions Unzip Task

The expression evaluates to the following.
-dc F:\location\20060831.filename.gz.file > F:\location\test

I'm stuck...|||

have you verified that the command you need to run can run from a dos prompt? you might want to try typing the command into a dos prompt to verify that it runs. that way, you can figure out if it's a gzip issue or an SSIS issue...

|||It works perfectly when I enter the command on the dos prompt

gzip -dc somefile.gz > somefile.txt

And when I enter

gzip -dc somefile.gz

The program executes properly and dumps the entire export of the file to the standard out and I see a large unzipped text file appear for a second in the cmd window. The problem arises when the > character appears.|||What about calling a simple command like ren (rename)

ren oldfilename.txt newfilename.txt

It's not possible to select cmd.exe as the executable and enter the rest as arguments. Any Thoughts?

Thanks|||

The File System task would be the better task to use to rename a file. you could use the execute process task with the following:

executable: C:\WINDOWS\system32\cmd.exe

arguments: /C ren testfile.txt renamed.txt

Frank

Calling commands from the cmd prompt

I have a series of commands that I need to run which decrypt, unzip, and rename

They are all one line commands when entered on the cmd prompt, is there an easy way to do this in ssis or should i write an exe and call them from there?

Thanks

Look at the Execute Process Task.

Frank

|||Yes, but the execute process task will execute a program. Granted I could make that program cmd.exe, I stuck on how to make an execute process task that will open up cmd and make the calls that I want. I could write a .exe file that that I could then put in the execute process task, I'm just curious if there's a way to do it w/ out writing my own script.exe file.

Thanks
|||

Yeah Frank is correct on this one. The execute Process task shells to a command prompt automatically for you an dissues pkunzip or whatever tool you're using to decompress the file. The Script task in this case would be an overkill. You can make the Execute Process task typically call PKunzip.exe in the command (make sure you point to the full path) then the argument would be the file name and any switches for override.

--Brian

|||I'm using gzip to decompress files.

the command I'd like to run is gzip -dc filetounzip > filenametosaveto

I'm having no problem running everything before the ">" character. This normally pipes the output to location filetosave to. Without the filenametosave to it dumps the output to the standard out.
I tried to put the filenametosave to in a variable in the standardoutputvariable property w/ no avail. The reason I'm using gzip is because I'm unzipping a .gz file.

Thanks
|||

you should use an expression for your argument property.

Frank

|||I have, when I do I get the following error

Error: 0xC0029151 at Positions Unzip Task, Execute Process Task: In Executing "C:\Program Files\GNU\Gzip\gzip.exe" "-dc F:\location\20060831.filename.gz.file > F:\location\test" at "", The process exit code was "1" while the expected was "0".
Task failed: Positions Unzip Task

The expression evaluates to the following.
-dc F:\location\20060831.filename.gz.file > F:\location\test

I'm stuck...

|||

have you verified that the command you need to run can run from a dos prompt? you might want to try typing the command into a dos prompt to verify that it runs. that way, you can figure out if it's a gzip issue or an SSIS issue...

|||It works perfectly when I enter the command on the dos prompt

gzip -dc somefile.gz > somefile.txt

And when I enter

gzip -dc somefile.gz

The program executes properly and dumps the entire export of the file to the standard out and I see a large unzipped text file appear for a second in the cmd window. The problem arises when the > character appears.
|||What about calling a simple command like ren (rename)

ren oldfilename.txt newfilename.txt

It's not possible to select cmd.exe as the executable and enter the rest as arguments. Any Thoughts?

Thanks
|||

The File System task would be the better task to use to rename a file. you could use the execute process task with the following:

executable: C:\WINDOWS\system32\cmd.exe

arguments: /C ren testfile.txt renamed.txt

Frank

Monday, March 19, 2012

Calling a VB exe from a stored procedure

Can someone tell me a straightforward way to call a VB app (that accepts command line arguments) from a stored procedure.

I have got it to work by using xp_cmdshell, but in practice, the security constraints here prevent using this. Our DBAs don't want to set the proxy account required for a non-sysadmin user to eexecute xp_cmdshell.

I know that writing an extended SP invoking a C++ dll would be the cleanest solution. However I don't have the knowledge to do that.

Any ideas?

ThanksOriginally posted by mtnlvrs
Can someone tell me a straightforward way to call a VB app (that accepts command line arguments) from a stored procedure.

I have got it to work by using xp_cmdshell, but in practice, the security constraints here prevent using this. Our DBAs don't want to set the proxy account required for a non-sysadmin user to eexecute xp_cmdshell.

I know that writing an extended SP invoking a C++ dll would be the cleanest solution. However I don't have the knowledge to do that.

Any ideas?

Thanks

I think your opening post eliminated the only two ways to do this (and actually, there's only one, since XP_CMDSHELL is just a very simple extended proc DLL)

Actually, just straight C will do for the DLL. It's not as hard as you seem to think. On the other hand, you gotta be sure of that code, since you'll be running in the engines address space. Just be sure to clean up everything, check your buffer lengths, and initialize all your pointers and it will work just fine. But I'm fairly certain extended procs are the only way to 'step outside' of what TSQL is capable of, ie run your VB code, and retain control flow.

Now, if it's OK for your VB code to run asynchronously, you could always make it step in a SQL Agent Job, and kick it off in a stored proc by executing msdb..sp_start_job, but you won't be able to return anything and your stored proc won't wait on the job to finish. And you'll have concurrency issues, as only one copy of a SQL Agent job can run at a time.

Wednesday, March 7, 2012

call regular phone number job completes

How can I have a sql agent job call a regular (land line) phone number when the job has completed? Any way to do this?
Thanks!
You could package some kind of DLL that will do this, then call it using
sp_OA* or an EXE from the command line using xp_cmdshell.
http://www.aspfaq.com/
(Reverse address to reply.)
"AshleyT" <anonymous@.discussions.microsoft.com> wrote in message
news:67DCD721-A327-460C-A576-954D2FB24716@.microsoft.com...
> How can I have a sql agent job call a regular (land line) phone number
when the job has completed? Any way to do this?
> Thanks!

call regular phone number job completes

How can I have a sql agent job call a regular (land line) phone number when the job has completed? Any way to do this
Thanks!You could package some kind of DLL that will do this, then call it using
sp_OA* or an EXE from the command line using xp_cmdshell.
--
http://www.aspfaq.com/
(Reverse address to reply.)
"AshleyT" <anonymous@.discussions.microsoft.com> wrote in message
news:67DCD721-A327-460C-A576-954D2FB24716@.microsoft.com...
> How can I have a sql agent job call a regular (land line) phone number
when the job has completed? Any way to do this?
> Thanks!

call regular phone number job completes

How can I have a sql agent job call a regular (land line) phone number when
the job has completed? Any way to do this?
Thanks!You could package some kind of DLL that will do this, then call it using
sp_OA* or an EXE from the command line using xp_cmdshell.
http://www.aspfaq.com/
(Reverse address to reply.)
"AshleyT" <anonymous@.discussions.microsoft.com> wrote in message
news:67DCD721-A327-460C-A576-954D2FB24716@.microsoft.com...
> How can I have a sql agent job call a regular (land line) phone number
when the job has completed? Any way to do this?
> Thanks!

call chart from rpt?

I'm sure this is a newbie question, but is there anyway to put a link or
button on a report line in a table or matrix to pull up a chart for the
information on that line (or lines in a matrix)?
--
Thanks,
CGW> I'm sure this is a newbie question, but is there anyway to put a link or
> button on a report line in a table or matrix to pull up a chart for the
> information on that line (or lines in a matrix)?
Yes - you can define the action property of the textbox with the line item,
and then drll through another report. Take a look at the Samples provided
with RS and described in RS Books OnLine, specifically the Territory Sales
Drilldown report.
--
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com|||Will do! Thanks!
"Dejan Sarka" wrote:
> > I'm sure this is a newbie question, but is there anyway to put a link or
> > button on a report line in a table or matrix to pull up a chart for the
> > information on that line (or lines in a matrix)?
> Yes - you can define the action property of the textbox with the line item,
> and then drll through another report. Take a look at the Samples provided
> with RS and described in RS Books OnLine, specifically the Territory Sales
> Drilldown report.
> --
> Dejan Sarka, SQL Server MVP
> Associate Mentor
> www.SolidQualityLearning.com
>
>

Friday, February 24, 2012

Calculations on members and aggregation

I'm designing a Profit And Loss report dimension that has the following attributes: Report Line, Cost Center and Account. Attribute relationships are defined between the attributes so that Report Line->Cost Center->Account.

A Report line is either A) A combination ofcost centers and accounts like:

Report Line A

- Cost Center 1

--Account 3000

--Account 3001

-Cost Center B

.. And so on

Or B) A calculation

I'm trying to handle calculations through mdx scripts by overwriting the value for those report lines that are calculations like:
scope (Report Line B);

this = Report Line A - Report Line C;

end scope

The problem is that the calculation report lines mess up the aggregation of the cube. I guess what I am really asking is wether its possible to turn off the members that are calculations in the aggregation of the cube. I realize i could use calculated measures for this but this doesnt fit my need for two reasons: Ease of use of the dimension and inability to drill down in reporting services on drillable members when calculated members are included.

Anyone have any ideas on this?

You can use the Freeze MDX statement to prevent changes to "Report Line B" from effecting the totals. To do this add simply apply Freeze to the all member of the hierarchy that contains Report Line B prior to updating Report Line B.

|||

Thanks!

Works like a charm, and as a bonus it helped me understand freeze