Sunday, July 10, 2022

[SOLVED] Python URL call using xdg Linux command

Issue

I have been trying to get this simple url call Linux command to run as a python script. However, I keep getting an error for too many arguments in the system() module. Is there is easy fix still using this technique?

import sys
import os
g = str(input('enter search '))
os.system('xdg-open https://',g)

Solution

format the command as a single string instead of 2 parameters

import sys 
import os

search = str(input('enter search')) 
os.system(f'xdg-open https://{search}')


Answered By - smcrowley
Answer Checked By - Candace Johnson (WPSolving Volunteer)