Zipping a txt file

Former Member
Former Member $organization

Hi

I'm trying to zip a Text file in SQL but once I run the command, sql keeps executing for long time and I don't get any error.

EXEC master..xp_cmdshell 'T:\Source\WinZip\winzip32.exe T:\Source\sso_pacingdata.zip T:\Source\sso_pacingdata.txt'

I also tried,

EXEC master..xp_cmdshell 'T:\source\WinZip\winzip32.exe -o T:\Source\sso_pacingdata.txt'

Probably my syntax is wrong. Can anyone please let me know the right syntax to Zip a Text file.

Thanks

Varsha

Parents
  • Former Member
    Former Member $organization

    Ben

     

    It worked, thanks a lot… I used –y switch to answer all Q Yes…

     

    exec master..xp_cmdshell '\\dell\tessitura\source\7-zip\7zG.exe a "\\dell\tessitura\source\sso_pacingdata.zip" "\\dell\tessitura\source\sso_pacingdata.txt" -y'

     

    Thanks a million…

     

    Varsha

     

    From: Tessitura Technical Forum [mailto:forums-technical@tessituranetwork.com] On Behalf Of Varsha Karnik
    Sent: Tuesday, 7 December 2010 2:22 PM
    To: Varsha Karnik
    Subject: RE: [Tessitura Technical Forum] Zipping a txt file

     

    Ben

     

    I can’t believe this,

     

    As per your script, I wrote thio=s code and it actually worked…

     

    exec master..xp_cmdshell '\\dell\tessitura\source\7-zip\7zG.exe a "\\dell\tessitura\source\sso_pacingdata.zip" "\\dell\tessitura\source\sso_pacingdataxt"'

     

    but the SQL is not stopping. The Zip is ready but I haven’t got any return outut in SQL. It’s still executing…

     

    what could be the problem? Does it need an output file?

     

    Thanks a lot…

     

    Varsha

     

    From: Tessitura Technical Forum [mailto:forums-technical@tessituranetwork.com] On Behalf Of Ben Gu
    Sent: Tuesday, 7 December 2010 2:07 PM
    To: Varsha Karnik
    Subject: RE: [Tessitura Technical Forum] Zipping a txt file

     

    Hi Varsha,

    I found a very interesting thing in  the xp_cmshell.

    this one work:

    exec master..xp_cmdshell 'c:\winzip\7z.exe a "c:\a\a.zip" "c:\a\a.txt"'

    this one doesn't:

    exec master..xp_cmdshell '"c:\winzip\7z.exe" a "c:\a\a.zip" "c:\a\a.txt"'

    ---

    but

    c:\winzip\7z.exe a "c:\a\a.zip" "c:\a\a.txt"

    and

    "c:\winzip\7z.exe" a "c:\a\a.zip" "c:\a\a.txt"

    both  work in cmd.

    have fun

    Ben

    From: Ben Gu <bounce-bengu4278@tessituranetwork.com>
    Sent: 12/6/2010 8:42:37 PM

    Hi Varsha,

    Good day.

    here is a way to use xp_cmdshell.

     


    steps to run xp_cmdshell.

    step1,


    stored procedure:

    create procedure lp_7zip
    WITH EXECUTE AS 'mynetwork\NetWorkAmdin'

    as
    begin

    exec master..xp_cmdshell 'c:\a\a.bat'  ---it is in sql server c: drive

    end


    step2


    in a.bat file


    --------------------------
    cd\
    "c:\winzip\7z.exe" a "\\mtc.com.au\mtc\Finance\Ben Gu\a\a.zip" "\\mtc.com.au\mtc\Finance\Ben Gu\a\a.txt"
    ------------------------------

    step3


    Credential account

    Credential name:
    ##xp_cmdshell_proxy_account##

    Identity:
    mynetwork\NetWorkAmdin
    passowrd:
    **********
    Comfirm passowrd:
    *********

     

    have fun

     

    Ben




    This message was sent automatically to you by www.tessituranetwork.com because you subscribed to the Tessitura Technical Forum. You may reply to this message to post to the Technical forum or visit the site to search, read and post to the forums. In the interest of keeping the forum posts from becoming cluttered, we encourage you to delete previous message text from your reply before sending. Thank you!




    This message was sent automatically to you by www.tessituranetwork.com because you subscribed to the Tessitura Technical Forum. You may reply to this message to post to the Technical forum or visit the site to search, read and post to the forums. In the interest of keeping the forum posts from becoming cluttered, we encourage you to delete previous message text from your reply before sending. Thank you!

  • Happy ending,

    You are welcome.

    Have fun.

    Ben

Reply Children
No Data